I am having trouble understanding some behavior I observed with multi-character unicode symbols.
Take, as an example, the string , and the regex (|)(?![]), I get three matches: Both flags, and the last hand. Expected: 5 matches, each symbol once.
Since both and are 2 character symbols, I tried writing a non-unicode example. With the string abcdabcdab and the regex (ab|cd)(?![b]), I get the expected 5 matches, each pair of ab and cd once.
Thinking that there might be some interaction between and , I used a different unicode character, giving me the regex (|)(?![]). Here I get the same result that I got in the first example.
Since both and are usually not used individually, I tried using "normal" unicode or ASCII characters instead of . I my example, I used and a, which gave me the expected result of 5 matches, each symbol once.
Is someone able to explain this behavior, or is this a bug?
This behavior only happened in PCRE and the JavaScript regex engine, I used this site to test it. https://regex101.com/