C ++ 11 regex :: icase inconsistent behavior

Based on perl-like regular expressions, I expected the code below to match regex'es in all 8 cases. But this is not so. What am I missing?

#include <iostream> #include <regex> #include <string> using namespace std; void check(const string& s, regex re) { cout << s << " : " << (regex_match(s, re) ? "Match" : "Nope") << endl; } int main() { regex re1 = regex("[AF]+", regex::icase); check("aaa", re1); check("AAA", re1); check("fff", re1); check("FFF", re1); regex re2 = regex("[af]+", regex::icase); check("aaa", re2); check("AAA", re2); check("fff", re2); check("FFF", re2); } 

Work with gcc 5.2:

 $ g++ -std=c++11 test.cc -o test && ./test aaa : Match AAA : Match fff : Nope FFF : Match aaa : Match AAA : Match fff : Match FFF : Nope 
+6
source share
1 answer

For future users, this was confirmed as a bug, and it (and similar problems) was solved with 8.1 according to this topic.

I suspect that the original author had a hand in drawing attention to this, but I thought that perhaps we could close it.

0
source

All Articles