赞助

正则表达式验证HTTP地址是否合法

转载:https://blog.csdn.net/fsdad/article/details/52637426

判断url是否合法

const std::regex urlpattern("^(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp)://)|(www\.))+(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9\&%_\./-~-]*)?$");
if (regex_match(strUrl.c_str(), urlpattern))
{
     //合法url
}
else
{
    //非法url
}

 

posted @ 2018-12-03 13:43  车臣  阅读(4076)  评论(0)    收藏  举报