// boostTest.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <boost/xpressive/xpressive_dynamic.hpp>
//BOOST用正则表达式验证ip地址合法
bool CheckIP(const char *ip)
{
using namespace boost::xpressive;
/* 定义正则表达式 */
cregex reg_ip = cregex::compile("(25[0-4]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])[.](25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])[.](25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])[.](25[0-4]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])");
return regex_match(ip, reg_ip);
}
int _tmain(int argc, _TCHAR* argv[])
{
std::wcout<<"ip:"<<CheckIP("1247.0.0.1");
getchar();
return 0;
}
boost用正则表达式验证ip地址合法
猜你喜欢
转载自blog.csdn.net/qq_23350817/article/details/107820033
今日推荐
周排行