- 代码
#include<string>
#include<regex>
#include <iostream>
using namespace std;
bool IsValidIP(const std::string& strIP)
{
std::string str="(((\\d{1,2})|(1\\d{1,2})|(2[0-4]\\d)|(25[0-5]))\\.){3}((\\d{1,2})|(1\\d{1,2})|(2[0-4]\\d)|(25[0-5]))(?=(\\b|\\D))";
cout<<"str="<<str<<endl;
std::regex regExpress(str);
return std::regex_match(strIP, regExpress);
}
int main()
{
bool bRet=IsValidIP("127.0.0.1");
cout<<"bRet="<<bRet<<endl;
getchar();
return 0;
}
-
msvc编译:
-
-
msvc运行结果:
返回值为true
5. mingw编译:
6. mingw运行结果:
返回值为false。
总结mingw能编译c++正则表达式,但是mingw运行C++正则表达式不对。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)