Indeed running
regex pattern("([a-z])((?!\\1)[a-z])");
cout << regex_match("aa", pattern) << endl;
results in the output "1", yet the first group matched is "a", and if instead I run
regex pattern("([a-z])((?!a)[a-z])");
cout << regex_match("aa", pattern) << endl;
I get "0" as expected.
Note that exactly the same regex works as expected in Python 3, i.e. running
re.match("([a-z])((?!\\1)[a-z])", "aa")
produces no matches. Can someone explain what is happening here?
Just for reference, I am using g++ (tdm64-1) 5.1.0 with flags -O2 and -std=c++11.
Because it was bugged in GCC5.
It works as expected in GCC6 and MSVC14.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With