C#验证邮箱,电话,手机,数字,英文,日期,身份证,邮编,网址,IP类等常用函数封装]?[a-zA-Z0-9]+)*)@([A-Za-z 0-9]+)(([.-]?[a-zA-Z0-9]+)*).([A-Za-z]{2,}) ,RegexOptions.IgnoreCase);
#endregion
#region验证网址
/**////s ummary
///验证网址
/// /summary
///param name=source/param
///r eturns/r eturnspublic statiRegexOptions.IgnoreCase);public static bool HasUrl(string source)return Regex.IsMatch(source, @(((file|g oph er|n ew s|nntp|te ln et|http|ftp|http s|ftps|s ftp)://)|(www.))+(([a-zA-Z0-9._-]+.[a-zA-Z]{2,6})|([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}))(/[a-zA-Z0-9 amp;%_./-~-]*)? ,RegexOptions.IgnoreCase);
#endregion
#region验证日期
/**////s ummary
///验证日期
/// /summary
///param name=source/param
///r eturns/returnspublic static bool IsDateTime(string source)
DateTime time=Convert.ToDateTime(sourc e);
return true;catchreturn fals e;
#endregion
#region验证手机号
/**////s ummary
///验证手机号
/// /s ummary
///param name=source/param
///r e tur ns/r e tur nspublic static bool IsMobile(string source)return Regex.IsMatch(s ourc e,@ [35]d{9}$,RegexOptions.IgnoreCas e);public static bool HasMobile(string source)return Regex.IsMatch(s ourc e,@1[35]d{9} ,RegexOptions.IgnoreCas e);
#endregion
#region验证IP
/**|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$ ,RegexOptions.IgnoreCase);public static bool HasIP(string source)return Regex.IsMatch(source, @(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9]) ,RegexOptions.IgnoreCase);
#endregion
#region验证身份证是否有效
/**////s ummary
///验证身份证是否有效
/// /s ummary
///param name=Id/param
///r e tur ns/r e tur nspublic static bool IsIDCard(string Id)if(I d.Length==18)bool check=IsIDCard18(Id);return c hec k;els e if(I d.Length==15)bool check=IsIDCard15(Id);return c hec k;return fals e;public static bool IsIDCard18(string Id)long n=0;if (long.TryParse(Id.Remove(17), out n) == false | | n Math.Pow(10, 16) | |long.TryP ars e(I d.Replac e(‘x’ , ‘0’).Replac e(‘X’ , ‘0’),out n)==fals e)return fals e;//数字验证string address =11x22x35x44x53x12x23x36x45x54x13x31x37x46x61x14x32x41x50x62x15x33x42x51x63x21x34x43x52x64x65x71x81x82x91if(addres s.IndexOf(Id.Remove(2))==-1)
return fals e;//省份验证string birth=Id.Subs tring(6,8).Ins ert(6, - ).Ins ert(4, -
DateTime time=new DateTime();if(DateTime.TryPars e(birth,out time)==fals e)return fals e;//生日验证string[] arrVar ifyCode=( 1,0,x,9,8,7,6,5,4,3,2).Split(‘ , ’);string[]Wi=(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2).Split(‘ , ’);c har[]Ai=Id.Remove(17).ToCharArray();int sum=0;for(int i=0; i i++)sum+=int.P ars e(Wi[i]) * int.P ars e(Ai[i].To String());int y=-1;
Math.DivR em(s um, 11,out y);if(arrVarify Code[y] !=Id.Substring(17, 1).ToLow er())return fals e;//校验码验证return true;//符合GB 11643-1999标准public static bool IsIDCard15(string Id)long n=0;if(long.TryPars e(Id,out n)==fals e | |n Math.Pow(10, 14))return fals e;//数字验证string address =11x22x35x44x53x12x23x36x45x54x13x31x37x46x61x14x32x41x50x62x15x33x42x51x63x21x34x43x52x64x65x71x81x82x91
if(addres s.IndexOf(Id.Remove(2))==-1)return fals e;//省份验证string birth=Id.Substring(6,6).Ins ert(4, - ).Ins ert(2, -
DateTime time=new DateTime();if(DateTime.TryPars e(birth,out time)==fals e)return fals e;//生日验证rd+$if(regex.Match(source).Success)if((long.Parse(source)0x7fffffffL) | | (long.Parse(source) -2147483648L))return fals e;return true;return fals e;
#endregion
#region看字符串的长度是不是在限定数之间一个中文为两个字符/**////s ummary
///看字符串的长度是不是在限定数之间一个中文为两个字符/// /s ummary
///param name=source字符串/param
///param name=begin大于等于/param
///param name=end小于等于/param
///r e tur ns/r e tur nspublic static bool IsLengthStr(string source, int begin, int end)
int length=Regex.Rep lac e(s ourc e,@[00-xff] ,OK).Length;if((length=b egin) (length=end))return fals e;return true;
#endregion
#region是不是中国电话格式010-85849685
/**////s ummary
///是不是中国电话格式010-85849685
/// /summary rc e)return Regex.IsMatch(s ourc e,@[u4e00-u9fa5]+,RegexOptions.IgnoreCas e);#endregion
#region验证是不是正常字符字母数字下划线的组合
/**////s ummary
///验证是不是正常字符字母数字下划线的组合
/// /s ummary
///param name=source/param
///r eturns/r eturnspublic static bool IsNormalChar(string source)return Regex.IsMatch(s ourc e,@[wd_]+,RegexOptions.IgnoreCas e);#endregion
ihostart怎么样?ihostart是一家国外新商家,主要提供cPanel主机、KVM VPS、大硬盘存储VPS和独立服务器,数据中心位于罗马尼亚,官方明确说明无视DMCA,对版权内容较为宽松。有需要的可以关注一下。目前,iHostART给出了罗马尼亚vps的优惠信息,罗马尼亚VPS无视DMCA、抗投诉vps/2核4G内存/40GB SSD/100M端口月流量2TB,€20/年。点击直达:ih...
HostHatch在当地时间7月30日发布了一系列的促销套餐,涉及亚洲和欧美的多个地区机房,最低年付15美元起,一次买2年还能免费升级双倍资源。商家成立于2011年,提供基于KVM架构的VPS主机,数据中心包括中国香港、美国、英国、荷兰、印度、挪威、澳大利亚等国家的十几个地区机房。官方网站:https://hosthatch.com/NVMe VPS(香港/悉尼)1 CPU core (12.5%...
快云科技已稳步运行进两年了 期间没出现过线路不稳 客户不满意等一系列问题 本司资质齐全 持有IDC ICP ISP等正规手续 有独特的网站设计理念 在前几天刚是参加过魔方系统举行的设计大赛拿获最佳设计奖第一名 本公司主营产品 香港弹性云服务器,美国vps和日本vps,香港物理机,国内高防物理机以及美国日本高防物理机 2020年的国庆推出过一款香港的回馈用户特惠机 已作为传家宝 稳定运行 马上又到了...