Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/146.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/8/http/4.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++ Can';t在C+中找出正则表达式+;_C++_Regex_Mingw - Fatal编程技术网

C++ Can';t在C+中找出正则表达式+;

C++ Can';t在C+中找出正则表达式+;,c++,regex,mingw,C++,Regex,Mingw,我对正则表达式不熟悉,不能真正理解它 我只是想匹配任何字母: int main() { regex("[a-z]") return 1; } 当我运行它时,我得到一个编译时错误: terminate called after throwing an instance of 'std::regex_error' what(): regex_error This application has requested the Runtime to terminate it in

我对正则表达式不熟悉,不能真正理解它

我只是想匹配任何字母:

int main() {
    regex("[a-z]")
    return 1;
}
当我运行它时,我得到一个编译时错误:

terminate called after throwing an instance of 'std::regex_error'
  what():  regex_error

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
但是,更简单的示例可以很好地工作:

int main() {
    regex("a")
    return 1;
}
我确信我缺少一些基本语法,我尝试添加regex::ECMAScript标志,但没有效果

请注意,我没有尝试使用regex对象,事实上我甚至没有存储它。我只是尝试使用构造函数创建它,如这里给出的示例所示:


编译器是GCC 4.8.1。

通过指定标志解决了问题:

regex("pattern", std::regex_constants::basic)

没有解释的反对票是怎么回事?无论如何,匹配是后一个问题,我只想创建一个对象,它是一个什么样的模式。什么编译器?什么版本?@JamesKanze gcc 4.8.1据我所知,正则表达式在g++4.8.2(我的版本)中不起作用;我怀疑它们在早期版本中是否有效。(您的代码在VS 2013中运行良好。)