C++ C++;std::使用lookahead的regex失败

C++ C++;std::使用lookahead的regex失败,c++,regex,std,C++,Regex,Std,我需要从磁盘解析一个txt文件。所以我首先做了一个例子,来测试正则表达式 这是我的示例代码: std::string txt("paragraph:\r\nthis is the text file\r\ni need only this data\r\nnotthis"); std::smatch m; std::regex rt("paragraph:([\\S\\s](?=notthis))"); std::regex_search(txt, m, rt); std::cout <

我需要从磁盘解析一个txt文件。所以我首先做了一个例子,来测试正则表达式

这是我的示例代码:

std::string txt("paragraph:\r\nthis is the text file\r\ni need only this data\r\nnotthis");
std::smatch m;
std::regex rt("paragraph:([\\S\\s](?=notthis))");
std::regex_search(txt, m, rt);

std::cout << m.str(1) << std::endl;

以前我没有使用过很多正则表达式,但是我已经被告知C++使用EcMAScript语法,但是在文档中,看起来前面的模式是相同的,并且只有LoopBeNeDS不被支持。如何在ecmascript中进行前瞻?

使用如下:

#include <iostream>
#include <string>
#include <regex>

int main()
{
std::string txt("paragraph:\r\nthis is the text file\r\ni need only this data\r\nnotthis");
std::smatch m;
std::regex rt("paragraph:([\\S\\s]+(?=notthis))");
std::regex_search(txt, m, rt);

std::cout << m.str(1) << std::endl;
}
#包括
#包括
#包括
int main()
{
std::string txt(“段落:\r\n这是文本文件\r\n我只需要此数据\r\n此文件”);
std::smatch m;
std::regex-rt(“段落:([\\S\\S]+(?=notthis))”;
标准::正则表达式搜索(txt、m、rt);
标准::cout
#include <iostream>
#include <string>
#include <regex>

int main()
{
std::string txt("paragraph:\r\nthis is the text file\r\ni need only this data\r\nnotthis");
std::smatch m;
std::regex rt("paragraph:([\\S\\s]+(?=notthis))");
std::regex_search(txt, m, rt);

std::cout << m.str(1) << std::endl;
}