Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • Maybe I am misunderstanding, but shouldn’t your example of looking for [abc] in abcacb show that the last matching index is 5 (the zero-based index of the last character of abcabc), not 3? What if you look for [abc] in abcd? Should that be 2? Will you need to generalize beyond looking for the last occurrence of a character class (e.g. needing to match something that is longer than a single character)? Commented Dec 15, 2012 at 8:01
  • @ChrisJohnsen The last matching index should be 5, indeed. And yes, once I found the first match I want to have it find further matches. Also a variant that returns all matched indexes at once would be of help. Thanks for pointing out my mistakes. Commented Dec 15, 2012 at 9:16