[英]‘multiline’ is not a member of ‘std::__cxx11::regex’
我正在尝试使用以下命令编译以下C ++代码:
g++ -std=c++17 -o rgx rgx.cpp
#include <iostream>
#include <regex>
#include <string>
using namespace std;
int main() {
regex rgx("^([A-Z]*)$", regex::ECMAScript | regex::multiline | regex::icase);
smatch rmtch;
string str = "AbcefgH\r\nTest";
if (regex_match(str, rmtch, rgx)) {
for (size_t i = 0; i < rmtch.size(); i++) {
ssub_match smtch = rmtch[i];
string s_m = smtch.str();
cout << " submatch " << i << ": " << s_m << endl;
}
}
return 0;
};
但是得到以下编译时错误
rgx.cpp: In function ‘int main()’:
rgx.cpp:7:53: error: ‘multiline’ is not a member of ‘std::__cxx11::regex’ {aka ‘std::__cxx11::basic_regex<char>’}
7 | regex rgx("^([A-Z]*)$", regex::ECMAScript | regex::multiline | regex::icase);
g++ --version
g++ (Ubuntu 9.1.0-8ubuntu1) 9.1.0
当我指定-std = c ++ 17时,为什么g ++使用__cxx11 :: regex?
cppreference.com/w/cpp/regex/basic_regex将regex::multiline
定义为C++17
标准的一部分
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.