首页 > 代码库 > 正则表达式
正则表达式
#include <regex>
const char* first = "";//需要验证的字符
std::regex rx("^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9]|X|x)$");//验证的表达式,这个是18位身份证的
//std::regex rx("^1[3|4|5|8][0-9]\\d{8}$");//这个是手机号
std::regex_constants::match_flag_type f1 =
std::regex_constants::match_default;
BOOL rv = std::regex_match(first,first+strlen(first),rx,f1);
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。