I have the following text:
aabbaa
aa bbc aa
bbg
aa bbd aa
I would like to find words that starts with bb
that are not between aa and aa
regardless of whitespaces preceding or following matching word using PCRE . In the above example only bbg
should be matched.
I have created the following pattern:
(?<!aa)bb(\w)*(?!aa)
However only aabbaa is not matched and other do. I don't know how can I use \s*
inside negative look ahead/behind to get desired result. It seems it cannot be simple done using:
(?<!aa\s*)bb(\w)*(?!\s*aa)
How can it be done?