
c#验证
caichunjia
这个作者很懒,什么都没留下…
展开
-
验证Int型,验证整数
#region 是不是Int型的 /// /// 验证整数 Int型 /// /// /// public bool IsInt(string source) { Regex regex = new Regex(@"^(-){0,1}\d+{1}quot;); if (regex.M转载 2011-12-19 17:07:52 · 941 阅读 · 0 评论 -
验证邮编
#region 验证邮编 6位 /// /// 验证邮编 6位 /// /// /// public bool IsPostCode(string source) { return Regex.IsMatch(source, @"^\d{6}{1}quot;", RegexOptions.Ignore转载 2011-12-19 17:16:00 · 399 阅读 · 0 评论 -
验证是否为中文
#region 验证中文 /// /// 验证中文 /// /// /// public bool IsChinese(string source) { return Regex.IsMatch(source, @"^[\u4e00-\u9fa5]+{1}quot;, RegexOptions.Ign转载 2011-12-19 17:18:26 · 258 阅读 · 0 评论 -
验证手机号
#region 验证手机号 /// /// 验证手机号 /// /// /// public bool IsMobile(string source) { return Regex.IsMatch(source, @"^1[358]\d{9}{1}quot;, RegexOptions.IgnoreC转载 2011-12-19 16:57:05 · 519 阅读 · 0 评论 -
验证邮箱
#region 验证邮箱 /**/ /// /// 验证邮箱 /// /// /// public bool IsEmail(string source) { return Regex.IsMatch(source, @"^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+转载 2011-12-19 16:52:13 · 306 阅读 · 0 评论 -
验证字符串长度范围
#region 验证字符串长度范围 /// /// 验证字符串长度范围 /// /// 字符串 /// 最大值 /// 最小值 /// public bool IsLengthStr(string source, int begin, int end) { int length = R转载 2011-12-19 17:11:38 · 664 阅读 · 0 评论 -
验证座机号码(中国 如:010-XXXXXXXX)
#region 验证座机号码(中国 如:010-XXXXXXXX) /// /// 验证座机号码(中国 如:010-XXXXXXXX) /// /// /// public bool IsTel(string source) { return Regex.IsMatch(source, @"^\d{3转载 2011-12-19 17:14:03 · 76221 阅读 · 0 评论 -
验证日期
#region 验证日期 /// /// 验证日期 /// /// /// public bool IsDateTime(string source) { try { DateTime time = Convert.ToDateTime(source);转载 2011-12-19 16:54:12 · 176 阅读 · 0 评论 -
验证网址
#region 验证网址 /**/ /// /// 验证网址 匹配字符串开始位置 /// /// /// public bool IsUrl(stringurl) { return Regex.IsMatch(url, @"^(((file|gopher|news|nntp|telnet|ht转载 2011-12-19 16:41:39 · 266 阅读 · 0 评论 -
验证IP
#region 验证IP /**/ /// /// 验证IP /// /// /// public bool IsIP(string source) { return Regex.IsMatch(source, @"^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}转载 2011-12-19 16:59:12 · 236 阅读 · 0 评论 -
验证 字母、数字、下划线
#region 验证 字母、数字、下划线 /// /// 验证 字母、数字、下划线 /// /// /// public bool IsNormalChar(string source) { return Regex.IsMatch(source, @"[\w\d_]+", RegexOptions.转载 2011-12-19 17:20:07 · 490 阅读 · 0 评论 -
验证身份证是否有效
#region 验证身份证是否有效 /// /// 验证身份证是否有效 /// /// /// public bool IsIDCard(string Id) { if (Id.Length == 18) { bool check = IsIDCard18(转载 2011-12-19 17:03:19 · 311 阅读 · 0 评论