[Bug libstdc++/61425] New: std::regex ignores backslash when using basic or grep grammars
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jun 5 20:22:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61425
Bug ID: 61425
Summary: std::regex ignores backslash when using basic or grep
grammars
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
CC: timshen at gcc dot gnu.org
#include <regex>
#include <iostream>
using namespace std;
int main()
{
regex_constants::syntax_option_type grammar[] = {
regex_constants::basic, regex_constants::grep
};
for (auto g : grammar)
{
regex re("a\\|b", g);
const char str[] = "a|b";
cmatch m;
if (regex_search(str, m, re))
cout << m.size() << ' ' << m[0] << endl;
}
}
There should be two matches, "a" and "b", instead there's only one:
1 a|b
1 a|b
The backslash seems to be ignored.
More information about the Gcc-bugs
mailing list