1.匹配IP地址
const std::regex pattern("^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$");
return std::regex_match(sIP, pattern);
const std::regex pattern("^((https|http|ftp|rtsp|mms)?://)+.*$");
return std::regex_match(strUrl, pattern);
const std::regex pattern("(\\b1[35][0-9]\\d{8}|147\\d{8}|1[8][01236789]\\d{8}\\b)");
return std::regex_match(phone, pattern);
参考网站: http://www.cnblogs.com/leejersey/p/3415422.html 点击打开链接
本文详细介绍了使用正则表达式匹配IP地址、URL和手机号码的方法,并提供了相关代码示例。主要内容包括:1. IP地址匹配;2. URL匹配;3. 手机号码匹配。
313

被折叠的 条评论
为什么被折叠?



