Use a sub-string twice in regular expressions

First of all, this question may have been asked before, but I am not sure what phrase to search for.

I have a string:

Maaaa

I have a pattern:

aaa< /p>

I want to match twice and give me starting indexes 1 and 2. But of course I only get one match (starting index 1) because the regular expression engine swallows all 3″a “And can’t use them again to leave me a mismatched “a”.

How can I solve this problem?

Thank you!

You can use lookahead assertions to find a followed by 2 a

a(?=aa)

First of all, this question may have been asked before, but I am not sure what phrase to search for. < p>

I have a string:

Maaaa

I have a pattern:< /p>

aaa

I want to match twice and give me starting indexes 1 and 2. But of course I only get one Match (starting index 1), because the regular expression engine swallows all 3 “a”s and cannot use them again to leave me a mismatched “a”.

How can I solve this problem?

Thank you!

You can use lookahead assertions to find a followed by 2 a

a(?= aa)

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5407 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.