str为传递过来的字符

E-Mail验证

Regex.IsMatch(str, @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", RegexOptions.Compiled);


用户ID验证
Regex.IsMatch(str, @"^[a-zA-Z][a-z0-9A-Z]*$", RegexOptions.Compiled);

用户密码验证(6到20位)
Regex.IsMatch(str, @"^[a-z0-9A-Z]{6,20}$", RegexOptions.Compiled);

时间验证
Regex.IsMatch(str, @"^[0-2][0-9][:][0-5][0-9]$", RegexOptions.Compiled);

数字验证  
Regex RegexEn = new Regex(@"^[0-9]+$");
RegexEn.IsMatch(str);
posted on 2008-06-18 21:15  人人人人人  阅读(211)  评论(0编辑  收藏  举报