Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.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++;11正则表达式分组_C++_Regex_C++11 - Fatal编程技术网

C++ C++;11正则表达式分组

C++ C++;11正则表达式分组,c++,regex,c++11,C++,Regex,C++11,可能重复: 我正在读这本涵盖C++11的书,我读到了关于正则表达式的章节。在我得到关于分组和引用\1的部分之前,一切都很顺利,只要我需要引用一个组。我的代码编译得非常好: #include <iostream> #include <regex> #include <string> int main() { try { regex r1("<(.*)>.*</\\1>");

可能重复:

我正在读这本涵盖C++11的书,我读到了关于正则表达式的章节。在我得到关于分组和引用\1的部分之前,一切都很顺利,只要我需要引用一个组。我的代码编译得非常好:

#include <iostream>
#include <regex>
#include <string>
int main()
{
     try
     {


           regex r1("<(.*)>.*</\\1>");
           bool found = regex_match(string("<tag>value</tag>"),r1);
           cout << "Does the string match:        ";
           cout << boolalpha << found << '\n';
     }catch( exception e)
     {
        cout << e.what() << '\n';
     }

     return 0;
}
#包括
#包括
#包括
int main()
{
尝试
{
正则表达式r1(“.”);
bool found=regex_匹配(字符串(“值”),r1);

coutlibstdc++对regex的实现非常不完整

请看第28节,正则表达式。如果您使用的是libstdc++(这在ubuntu上几乎是肯定的),那么您还不能使用正则表达式

遗憾的是,g++的C++11工具链在其他方面非常可靠


您可能需要使用boost或其他正则表达式库,或者更改clang(和clang的库)或MSVC(和它们的库).

是的,在g++/libstdc++下它不工作。因为它还没有实现。哦,对不起,我误读了你的评论。你知道其他编译器已经完全实现了它吗?如果我没记错的话,是Clang和MSVC。)谢谢你,我感谢你的帮助help@user1274223:显然不足以接受答案。。。