I'm fairly knowledgeable with regex, but I still can't rap my finger around this match.
I have the following string aaaaaabcaaaaaaa
which is matched by the following regex caaa|aab|aaa
. What I'm expecting is caaa, aab, aaa
, and what I'm getting is aaa, caaa, aaa
.
Can some regex guru please tell me, why I can't get the expected result with this regex?
Thank you.
let string = 'aaaaaabcaaaaaaa',
regexp = /caaa|aab|aaa/g;
while( match = regexp.exec( string ) )
console.log( match );