First, this question may have been asked before, but I'm not sure what phrase to search on.
I have a string:
Maaaa
I have a pattern:
aaa
I would like to match twice, giving me starting indices of 1 and 2. But of course I only get a single match (start index 1), because the regex engine gobbles up all 3 "a"s and can't use them again, leaving me with 1 "a" which doesn't match.
How do I solve this?
Thanks!
You could use a lookahead assertion to find an a followed by 2 a's
a(?=aa)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With