判断是否为手机号:
If(Regex.IsMatch(nickName, @"^0{0,1}(13[4-9]|15[7-9]|15[0-2]|18[7-8])[0-9]{8}$")) { ... }
or
If(Regex.IsMatch(nickName, @"^1(3|4|5|7|8)[0-9]\d{8}$")){ ... }
提取汉字:
public string ExtractChinese(string strValue) { string x = @"[\u4E00-\u9FFF]+"; MatchCollection Matches = Regex.Matches(strValue, x, RegexOptions.IgnoreCase); if (Matches.Count > 0) { string str = Matches[0].Value; return str; } else return ""; }
转载于:https://www.cnblogs.com/xiaoxiaomini/p/8251702.html