RegexOptions.ECMAScript)){obj.Code = ErrorType.Business.ToS

时间:2022-01-18 08:16:45

C# 常用正则表达式正则表达式

if (!Regex.IsMatch(model.phone, @"^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$", RegexOptions.ECMAScript)) { obj.Code = ErrorType.Business.ToString(); obj.ErrorMsg = "手机格局不正确!"; return obj; } if (!Regex.IsMatch(model.tel, @"^(\d{3,4}-)?\d{6,8}$", RegexOptions.ECMAScript)) { obj.Code = ErrorType.Business.ToString(); obj.ErrorMsg = "电话号码格局不正确!格局要求(区号+电话号码)"; return obj; }