https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77492
--- Comment #2 from Danila <flashmozzg at gmail dot com> --- (In reply to Tim Shen from comment #1) > Seems to be the same issue as 71500. Even though I assume that that bug (71500) was fixed (even though the status is still UNCONFIRMED) it haven't fixed the issue. I tried with both latest gcc (7.2) and clang (5.0) on Ubuntu 16.04 and in both cases the result of this simple code was the same: #include <iostream> #include <regex> using namespace std; void check(const string& s, regex re) { cout << s << " : " << (regex_match(s, re) ? "Match" : "Nope") << endl; } int main() { regex re1 = regex("([a-z]+) \\1", regex::icase); check("abc abc", re1); check("Abc abc", re1); check("abc Abc", re1); } output: abc abc : Match Abc abc : Nope abc Abc : Nope It looks like both compilers don't ignore the case of the backreferences which looks like a bug. I haven't found any exceptions to the icase flag in case of backrefs and this how it works in most languages. Also, it looks like Visual C++ compiler works with this case correctly (i.e. it matches the string in all 3 cases).