Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/149.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.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
为什么正则表达式阻塞在replace上? 为什么这段C++代码块永远存在?< /P> string word = " a\n"; regex indent("^( |\t)*"); word = regex_replace(word, indent, ""); 为什么这段C++代码会很快终止?< /P> string word = " a\n"; regex indent("^( |\t)+"); word = regex_replace(word, indent, ""); string word = " a\n"; regex indent("^( |\t)+?"); word = regex_replace(word, indent, "");_C++_Regex - Fatal编程技术网 string word = " a\n"; regex indent("^( |\t)+"); word = regex_replace(word, indent, ""); string word = " a\n"; regex indent("^( |\t)+?"); word = regex_replace(word, indent, "");,c++,regex,C++,Regex" /> string word = " a\n"; regex indent("^( |\t)+"); word = regex_replace(word, indent, ""); string word = " a\n"; regex indent("^( |\t)+?"); word = regex_replace(word, indent, "");,c++,regex,C++,Regex" />

为什么正则表达式阻塞在replace上? 为什么这段C++代码块永远存在?< /P> string word = " a\n"; regex indent("^( |\t)*"); word = regex_replace(word, indent, ""); 为什么这段C++代码会很快终止?< /P> string word = " a\n"; regex indent("^( |\t)+"); word = regex_replace(word, indent, ""); string word = " a\n"; regex indent("^( |\t)+?"); word = regex_replace(word, indent, "");

为什么正则表达式阻塞在replace上? 为什么这段C++代码块永远存在?< /P> string word = " a\n"; regex indent("^( |\t)*"); word = regex_replace(word, indent, ""); 为什么这段C++代码会很快终止?< /P> string word = " a\n"; regex indent("^( |\t)+"); word = regex_replace(word, indent, ""); string word = " a\n"; regex indent("^( |\t)+?"); word = regex_replace(word, indent, "");,c++,regex,C++,Regex,再加上一个转折点,为什么这会很快终止 string word = " a\n"; regex indent("^( |\t)+"); word = regex_replace(word, indent, ""); string word = " a\n"; regex indent("^( |\t)+?"); word = regex_replace(word, indent, ""); 我希望“^(|\t)+?”与“^(|\t)*” 我使用LBC+++和LLVM和标准C++正则表达式库。

再加上一个转折点,为什么这会很快终止

string word = " a\n";
regex indent("^( |\t)+");
word = regex_replace(word, indent, "");
string word = " a\n";
regex indent("^( |\t)+?");
word = regex_replace(word, indent, "");
我希望
“^(|\t)+?”
“^(|\t)*”


我使用LBC+++和LLVM和标准C++正则表达式库。

< P>代码是好的。正则表达式库在您的libc++版本中大多没有实现。您最好使用另一个库,如boost或更新版本的libc++。

我的猜测是,
^(|\t)*
不匹配任何内容(即*表示0或更多,因此它匹配一个空格、一个选项卡或空字符串),而现有的(错误的)算法在输入字符串中找不到任何内容。。。永远。换句话说,您在regex实现中遇到了一个bug。

我下载并编译了libc++的最新版本,并且
“^(|\t)*”
版本不再阻塞。所以我要把它记在一个旧库中。

上次我听说libstdc++的
不完整。