I need to get the following regex to pass at https://regex101.com I will include
ID: 3753424 • Letter: I
Question
I need to get the following regex to pass at https://regex101.com I will include the tests cases and what i have so far for the regex expression..
All words in which a is tripled and b is tripled, but not both. This means each word contains the substring aaa or the substring bbb but not both
This is the following regex expression that I currently have but still cant get it to pass all the test cases
^(((a|ba|bba)*|((bb|b|)))aaa(a|ba|bba)*|(bb|b|)|(((b|ab|aab)*|(aa|a|))bbb((b|ab|aab))*|(aa|a|)))$
These strings should have FULL matching
aaa
bbb
baaab
abbba
abbb
bbba
baaa
aaab
abaaaab
aaaaaaa
bbbbbbb
bbaaabb
These strings should NOT have FULL matching:
bbbaaa
aaabbb
abba
a
b
ab
ba
abab
aabb
aaababababbb
bbbabababaaa
Explanation / Answer
aaa(?!bbb)|(?<!bbb)aaa
I have tried but try to build more upon this
aaa(?!bbb) - matches a aaa only if is not followed by bbb, but bbb will not be part of the overall regex match
(?<!bbb)aaa - matches a aaa only if is not preceded by an bbb, but bbb will not be part of the overall regex match
I hope this helps.