C++正则匹配Url信息
版权声明:
本文为博主原创文章,转载请声明原文链接...谢谢。o_0。
更新时间:
2023-07-08 13:41:33
温馨提示:
学无止境,技术类文章有它的时效性,请留意文章更新时间,如发现内容有误请留言指出,防止别人"踩坑",我会及时更新文章
正则分隔url主机,路径,协议等信息
regex reg("^(https?://)(.+?)(/.*)?$", regex::icase);
//string url = "https://blog.csdn.net/aaaaaa/abbbbe/detccccs/1eeee31";
string url = "https://blog.csdn.net/";
//string url = "https://blog.csdn.net";
smatch result;
bool ret = regex_match(url, result, reg);
if (result.size() == 4) {
OutputDebugStringA(result[1].str().c_str());
OutputDebugStringA(result[2].str().c_str());
OutputDebugStringA(result[3].str().c_str());
}