Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/139.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 表达式包含无效的排序元素名称c++;正则表达式_C++_Regex - Fatal编程技术网

C++ 表达式包含无效的排序元素名称c++;正则表达式

C++ 表达式包含无效的排序元素名称c++;正则表达式,c++,regex,C++,Regex,我有一个正则表达式。我在字符串中找到正则表达式。但是,每次运行(而不是编译它)时,都会出现以下错误:表达式包含无效的排序元素名称。这是我的正则表达式: :\w*:{[\w\s-+=\/*^%!;\(\)\[\]\{\}]*}:funcEND: 当我在程序中使用它时: regex常量函数regex(“:\\w*:\{[\\w\\s-+=\\/*^%!;\\(\\)\[\\]\{\\}]*\\}:funcEND:” 有人能告诉我为什么这会引起错误吗?我在网上查了一下,但找不到我能用的东西。我还查看了

我有一个正则表达式。我在字符串中找到正则表达式。但是,每次运行(而不是编译它)时,都会出现以下错误:
表达式包含无效的排序元素名称
。这是我的正则表达式:
:\w*:{[\w\s-+=\/*^%!;\(\)\[\]\{\}]*}:funcEND:

当我在程序中使用它时:
regex常量函数regex(“:\\w*:\{[\\w\\s-+=\\/*^%!;\\(\\)\[\\]\{\\}]*\\}:funcEND:”
有人能告诉我为什么这会引起错误吗?我在网上查了一下,但找不到我能用的东西。我还查看了regex wiki

以下是一些应该匹配的文本:

:functionDetector:{
    foo=foo+bar;
}: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;
regex常量函数regex(“:\\w*:\{[\\w\\s-+=\\/*^%!;\\(\\)\[\\]\{\\}]*\\}:funcEND:”;
ptrdiff_t const matchCount(距离(sregx_迭代器(content.begin()、content.end()、functionRegex)、sregx_迭代器());
ostringstream Extrafuncinoss;

extraFuncInfoOSS将破折号转义为
-
,或使其成为开头方括号后的第一个字符
[d/代码>。方块有一个特殊的含义,方括号。

可能是因为您没有发布说明您问题的可编译代码。抱歉。我不知道它是需要的,因为它是关于正则表达式的问题。它是关于C++正则表达式实现的问题。好的,请说明。源已被添加。这仍然不是COMPI。标签。谢谢!我使用的网站没有提到这一点!
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;