1:只能为数字(包括小数点):
string pattern = @"^\d+(\.\d+)?$";2:除去特殊字符:
string pattern = @"[~!!^;?@#¥$%……&*——{}?。,,‘’“”|》《':]";3:邮政编码:
string pattern = @"^[0-9]{6}$";4:手机号码:
string pattern = @"^13[0-9]{9}$|14[0-9]{9}|15[0-9]{9}$|18[0-9]{9}$";5:URL:
string pattern = @"^(\w+:\/\/)?\w+(\.\w+)+.*$";6:邮箱:
string pattern = @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$";
7:身份证:
string pattern = @"^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$";8:月份:
string pattern = @"^([1-9]|1[0-2])$";9:日期:
string pattern = @"^([0-2]?[0-9]|3[0-1])$";10:小时:
string pattern = @"^([0-1][0-9]|2[0-3])$";11:秒:
string pattern = @"^[0-5]?[0-9]$";原文链接:https://www.f2er.com/regex/361412.html