#include <regex>
#include <string>
#include <iostream>
#include<fstream>
using namespace std;
int main()
{
string str="\"time\":2021-02-27,\"parament\":hello world,\"ip\":201.233.5.78,\"other\":ga21#";
regex repattern1("(?<=\"parament\":).*(?=,\"ip\")");
smatch match1;
string replace1="*";
regex_match(str,match1,repattern1);
cout<<boolalpha<<regex_match(str,repattern1)<<endl;
cout<<match1[0]<<endl;
cout<<regex_replace(str, repattern1, replace1)<<std::endl;
system("pause");
return 0;
}
这段代码匹配"time":2021-02-27,"parament":hello world,"ip":201.233.5.78,"other":ga21#中"parament":和,"ip"之间的内容,并将内容匹配为*,但是运行后直接就退出了,也没有替换成功,请问各位这是什么原因?