正则表达式为什么匹配不到Group(3)?

sb3day sb3day 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
bool TestRegex(char *lpLink)
{
string strLink(lpLink);
static CRegexpT<char> rgxField("event:(.*)\\|(\\d+)\\|(.*)", IGNORECASE);
MatchResult matchresult = rgxField.Match(strLink.c_str());
bool bRet = matchresult.IsMatched()!=0;

if(bRet)
{
printf("TestRegex MaxGroupNumber=%d:\n",matchresult.MaxGroupNumber());
for(int i=1;i<matchresult.MaxGroupNumber();i++)
{
int nStart = matchresult.GetGroupStart(i);//event:release|2|
int nEnd = matchresult.GetGroupEnd(i);

string strType = strLink.substr(nStart, nEnd-nStart);
printf("%s\n",strType.c_str());
}
}

return bRet;
}

TestRegex("event:release|4|9a631c7d-5c54-43e0-99a6-76f89bf7910e|80709283-ee51-45ef-9b20-a46ef4d1a570");

我用"event:(.*)\\|(\\d+)\\|(.*)"为什么匹配不到"event:release|4|9a631c7d-5c54-43e0-99a6-76f89bf7910e|80709283-ee51-45ef-9b20-a46ef4d1a570"
的Group(3)呢?要怎么解决?我用的是跨平台的deelx正则库
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
sb3day
C++ 语言 65,214 成员 250,514 内容