我有一个雷吉士。我正在寻找一个字符串中的正则表达式。但是,每次运行(而不是编译它)时,我都会得到以下错误:
The expression contained an invalid collating element name
. 这是我的regex:
:\w*:{[\w\s-+=\/*^%!;\(\)\[\]\{\}]*}:funcEND:
.
当我在程序中使用它时:
regex const functionRegex(":\\w*:\\{[\\w\\s-+=\\/*^%!;\\(\\)\\[\\]\\{\\}]*\\}:funcEND:");
.
有人能告诉我为什么会产生错误吗?我在网上查了一下,但找不到我能用的东西。我还查看了regex wiki。
以下是一些应匹配的文本:
:functionDetector:{
foo=foo+bar;
}:funcEND:
还有:
:foo:{
// hello world
}:funcEND:
以下是一些不匹配的文本:
^BANK^{
foo=1;
bar=5;
}^BANK^
^UPDATE^{
CALL:functionDectector;
}^UPDATE^
:hello:{
// goo
}:qwerty:
源代码:
regex const functionRegex(":\\w*:\\{[\\w\\s-+=\\/*^%!;\\(\\)\\[\\]\\{\\}]*\\}:funcEND:");
ptrdiff_t const matchCount(distance(sregex_iterator(content.begin(), content.end(), functionRegex), sregex_iterator()));
ostringstream extraFuncInfoOSS;
extraFuncInfoOSS << "Extra functions detected: " << matchCount << "...";
cout << extraFuncInfoOSS.str() << endl;