Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.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++中的正则表达式投掷错误“无效特殊开括号”。_C++_Regex_Pcre - Fatal编程技术网

C++中的正则表达式投掷错误“无效特殊开括号”。

C++中的正则表达式投掷错误“无效特殊开括号”。,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

我目前正在处理这样一个问题:

a、 b.c.d.e~f

我试图提取a,b,c,d,e和f


我在提取周期分隔值方面取得了一些进展,但我仍然被卡住了,因为我使用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]\\)";