C++中的正则表达式投掷错误“无效特殊开括号”。
我目前正在处理这样一个问题: a、 b.c.d.e~f 我试图提取a,b,c,d,e和fC++中的正则表达式投掷错误“无效特殊开括号”。,c++,regex,pcre,C++,Regex,Pcre,我目前正在处理这样一个问题: a、 b.c.d.e~f 我试图提取a,b,c,d,e和f 我在提取周期分隔值方面取得了一些进展,但我仍然被卡住了,因为我使用PCRE?提取由tilde~前缀的最后一个元素的特殊查询,如果要使用括号,需要用反斜杠将其转义 以下是一个例子: std::string regexstring = "\\([a-z]\\):\\([0-9]\\)"; 他不是想和帕伦斯配对,而是想和小组配对。你知道了吗?对于std::regex?:^ |,?=[^\]\?\?\|$ #in
我在提取周期分隔值方面取得了一些进展,但我仍然被卡住了,因为我使用PCRE?提取由tilde~前缀的最后一个元素的特殊查询,如果要使用括号,需要用反斜杠将其转义 以下是一个例子:
std::string regexstring = "\\([a-z]\\):\\([0-9]\\)";
他不是想和帕伦斯配对,而是想和小组配对。你知道了吗?对于std::regex?:^ |,?=[^\]\?\?\|$
#include <string>
#include <iostream>
#include <regex>
using namespace std;
int main() {
const string example = "a.b.c~height";
regex regex_query_path(R"rgx([^.]+(?=[^~]*~))rgx");
std::smatch m;
string test = example;
while (std::regex_search (test,m,regex_query_path)) {
cout << "path: " << m[0] << endl;
test = m.suffix().str();
}
regex regex_query_name(R"rgx((?<=~).*)rgx");
test = example;
while (std::regex_search (test,m,regex_query_name)) {
cout << "query: " << m[0] << endl;
test = m.suffix().str();
}
return 0;
}
std::string regexstring = "\\([a-z]\\):\\([0-9]\\)";