我第一次尝试 C++ 正则表达式,我使用了从 cplusplus.com 最小化的示例,但我总是遇到运行时错误..
代码:
#include <iostream>
#include <regex>
int main () {
std::string s = "there is a subsequence in the string\n";
std::string e = "$1 and $2";
std::cout << regex_replace(s, std::regex("\\b(sub)([^ ]*)"), e);
return 0;
}
编译:
mingw32-g++.exe -std=c++11 -c C:\Users\Daniel\Desktop\test.cpp -o C:\Users\Daniel\Desktop\test.o
mingw32-g++.exe -o C:\Users\Daniel\Desktop\test.exe C:\Users\Daniel\Desktop\test.o
错误:
回答:gcc 4.8 或更早版本是否存在关于正则表达式的错误?@R。马蒂尼奥费尔南德斯