首先需要引用:using System.Text.RegularExpressions;
数字正则表达式 private static Regex RegNumber = new Regex(@"^[0-9]+$");
数字可带正负号 private static Regex RegNumberSign = new Regex(@"^[+-]?[0-9]+$");
十进制数 private static Regex RegDecimal = new Regex(@"^[0-9]+[.]?[0-9]+$");
带符号十进制数 private static Regex RegDecimalSign = new Regex(@"^[+-]?[0-9]+[.]?[0-9]+$");
Email正则表达式 private static Regex RegEmail = new Regex(@"^(\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+[,]{0,1})+$");
中文字符正则表达式 private static Regex RegCHZN = new Regex(@"[\u4e00-\u9fa5]");
双字节字符正则表达式(包括汉字在内) private static Regex RegDoubleByte = new Regex(@"[^\x00-\xff]");
IP地址正则表达式 private static Regex RegIP = new Regex(@"^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$");
URL正则表达式 private static Regex RegURL = new Regex(@"^http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$");
日期[2004-2-29|||2004-02-29 10:29:39 pm|||2004/12/31]正则表达式 private static Regex RegDate = new Regex(@"^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[1-9])|(1[0-2]))\:([0-5][0-9])((\s)|(\:([0-5][0-9])\s))([AM|PM|am|pm]{2,2})))?$");
ANSI SQL date正则表达式 private static Regex RegSQLDate = new Regex(@"^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578]
)|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[4
69])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\
s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([1
3579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((
0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((
0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9]
)|(2[0-8]))))))(\s(((0?[1-9])|(1[0-2]))\:([0-5][0-9])((\s)|(
\:([0-5][0-9])\s))([AM|PM|am|pm]{2,2})))?$");
中国邮政编码正则表达式 private static Regex RegCNMailCode = new Regex(@"^[1-9]\d{5}$");
身份证号码正则表达式 private static Regex RegIDcard = new Regex(@"^\d{15}|\d{17}[\dx]$");
中国电话号码正则表达式 private static Regex RegPhoneCode = new Regex(@"(^(\d{2,4}[-_-—]?)?\d{3,8}([-_-—]?\d{3,8})?([-_-—]?\d{1,7})?$)|(^0?1[35]\d{9}$)");