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.
Aucun commentaire:
Enregistrer un commentaire