天天看点

正则表达式 匹配 电话号码

string regexStr = "([1][0-9]{10})"; //手机号码
System.Text.RegularExpressions.MatchCollection mc = System.Text.RegularExpressions.Regex.Matches(str, regexStr);
foreach (System.Text.RegularExpressions.Match m in mc)
{
      m.Groups[0].Value;        
}
           

([1][0-9]{10})

其中

[1]表示首位为1

[0-9]表示0-9的任意数字

{10}表示取10个

[0-9]{10} 表示取10个连续数值为0到9的任意数字

继续阅读