且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C++ std::regex 使用前瞻失败

更新时间:2023-02-20 07:53:00

使用方法如下:

#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;
}