using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace MyCode.Project.Infrastructure.Utils { /// /// 验证工具 /// public class ValidUtil { /// /// 验证手机号是否正确 /// /// /// public static bool IsMobile(string mobile) { if (string.IsNullOrEmpty( mobile) || mobile.Length != 11) { return false; } Regex rx = new Regex(@"\d{11}"); //Regex rx = new Regex(@"^0{0,1}(13[4-9]|15[7-9]|15[0-2]|17[7-8]|18[7-8])[0-9]{8}$"); if (!rx.IsMatch(mobile)) //不匹配 { return false; } else { return true; } } } }