I have a very long string (2k chars) and I want to match every occurrence that has:
aaa
+ anything + bbb
+ anything + ccc
For example, I would like matches like:
aaa xx bbb y ccc
aaa uuu o bbb l iii ccc
This would be easy to obtain with regex, BUT there is a catch: all the matches can only have aaa
at the beginning, I cant have aaa
anywhere in the middle of the matches.
I tried this regex /aaa.+?bbb.+?ccc/
but it matches things like aaa h bbb aaa ccc
which is not what I need because aaa
is also in the middle.
After searching in Google, I think I need to use negative lookahead but I got lost and nothing worked. Do you have any suggestion to solve this problem using only regex without doing any other string manipulation (explode, splits…)?