📄 match.cpp
字号:
# include<iostream>
# include<fstream>
# include <cstdio>
# include<string>
# include<regex.h>
# define nmatch 5
using namespace std;
string GetMatchContent(string strContent,string matchContent)
{
regex_t preg;
string content;
char regex[]="[0-9]+\\.[0-9]+";
regmatch_t pmatch[nmatch];
int position=strContent.find(matchContent);
if(position<0)
return "";
string tempStr=strContent.substr(position,50);
if(regcomp(&preg,regex,REG_EXTENDED)==0)
{
if(regexec(&preg,tempStr.c_str(),nmatch,pmatch,0)==0)
{
for(int i=0;i<5;i++)
{
if(pmatch[i].rm_so==-1)
continue;
content=tempStr.substr(pmatch[i].rm_so,pmatch[i].rm_eo-pmatch[i].rm_so);
}
}
}
regfree(&preg);
return content;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -