Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/132.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++11下使用正则表达式_C++_Regex - Fatal编程技术网

在c++11下使用正则表达式

在c++11下使用正则表达式,c++,regex,C++,Regex,可能重复: 我试图用ReGEX在C++下转换一个文件,一些ReXEXY错误不断发生, 代码如下: std::ifstream inf(in); std::ofstream outf(out); try{ std::regex line_regex("[[:alnum:]]"); std::string line; while(std::getline(inf,line)) { if(std::regex_match(line,line_regex)) outf<&

可能重复:

我试图用ReGEX在C++下转换一个文件,一些ReXEXY错误不断发生, 代码如下:

std::ifstream inf(in);
std::ofstream outf(out);
try{
std::regex line_regex("[[:alnum:]]");
std::string line;
while(std::getline(inf,line))
{
    if(std::regex_match(line,line_regex))
        outf<<line<<std::endl;
}

顺便说一下,我正在linux x64上使用gcc 4.7.2。

gcc的实现无法使用。不要在上面浪费时间。

GCC的实现无法使用。不要在上面浪费时间。

gcc版本4.6.1只对std::regex提供了部分支持,我不知道它是否已经在版本4.7.0中修复,我想他们还没有修复。在这里检查regex,我在4.6.2上尝试了std::regex,但也无法使它工作。结果却包裹了PCRE。我认为Perl regex语法是最好的、最具表现力的,PCRE是一个非常稳定的历史悠久的库。gcc版本4.6.1仅部分支持std::regex,我不知道它是否在版本4.7.0中得到了修复,再想一想,我想他们还没有修复它,在这里检查regex,我在4.6.2上尝试了std::regex,但也无法让它工作。结果却包裹了PCRE。我认为Perl正则表达式语法是最好、最具表现力的,PCRE是一个非常稳定的历史悠久的库。是的,我使用boost版本,它工作得很好。@flyingfoxlee-和Microsoft版本一样。是的,我使用boost版本,它工作得很好。@flyingfoxlee-和Microsoft版本一样。
terminate called after throwing an instance of 'std::regex_error'
what():  regex_error