我想从这样的用户表中取出所有用户的手机号,只要手机号:
E0601 y1-1-101 金春爽 13911178654、62913474
E0601 y1-1-102 李晓荣 13683127618、80792886
E0601 y1-1-201 陈宇 13683675592
E0601 y1-1-202 刘冬嫄 13681307588、81729622
E0601 y1-1-301 田英伟 13366911392、13359442595
E0601 y1-1-302 郝振炜 82917074、13661379553、13683623250
E0601 y1-1-401 孙建丽 13671160899、65250534、81706331
E0601 y1-1-402 王佳楠 13671215635
E0601 y1-1-501 田瑞昌 62914978
E0601 y1-1-502 杨海兵 13311572107
E0601 y1-1-601 陈晓燕 13911880873、62310697
E0601 y1-1-602 卢新华 13641251583
E0601 y1-2-101 赵彪 13520268007、51059160
E0601 y1-2-102 赵宝胜 13501289370、13311394291
E0601 y1-2-201 李淋 13621203739、62714358
E0601 y1-2-202 皇甫云宝13552055385、65854393
E0601 y1-2-301 梁军 13671283936、69737883
E0601 y1-2-302 王树成 13522005656、65076936
E0601 y1-2-401 陈显金 64916805、13701037265
E0601 y1-2-402 陈丽娟 13601029067、62475088
E0601 y1-1-101 金春爽 13911178654、62913474
E0601 y1-1-102 李晓荣 13683127618、80792886
E0601 y1-1-201 陈宇 13683675592
E0601 y1-1-202 刘冬嫄 13681307588、81729622
E0601 y1-1-301 田英伟 13366911392、13359442595
E0601 y1-1-302 郝振炜 82917074、13661379553、13683623250
E0601 y1-1-401 孙建丽 13671160899、65250534、81706331
E0601 y1-1-402 王佳楠 13671215635
E0601 y1-1-501 田瑞昌 62914978
E0601 y1-1-502 杨海兵 13311572107
E0601 y1-1-601 陈晓燕 13911880873、62310697
E0601 y1-1-602 卢新华 13641251583
E0601 y1-2-101 赵彪 13520268007、51059160
E0601 y1-2-102 赵宝胜 13501289370、13311394291
E0601 y1-2-201 李淋 13621203739、62714358
E0601 y1-2-202 皇甫云宝13552055385、65854393
E0601 y1-2-301 梁军 13671283936、69737883
E0601 y1-2-302 王树成 13522005656、65076936
E0601 y1-2-401 陈显金 64916805、13701037265
E0601 y1-2-402 陈丽娟 13601029067、62475088
string a=reg.Match("13911178654、62913474").Value;
System.Text.RegularExpressions.Regex reg=new System.Text.RegularExpressions.Regex(@"1\d{10}");
foreach (Match m in reg.Matches("E0918 r17-5-501 徐佳 13488853727、13910374072、13501266549、81721605、62586666-245"))
{
string a=m.Value;
}
string[] str = strphone.Split('、');
foreach (string s in str)
{
if (s.Length == 11)
{
string sphone = s.Substring(0,1);
if ( sphone== "1")
{
MessageBox.Show(sphone);
//s这个条件成立,s就是你要的手机号码
}
}
}
你的就不行了
ArrayList returnList = new ArrayList();
string pattern = @"(?<cell>\d{11})";
Regex regex = new Regex(pattern);
MatchCollection matchList = regex.Matches(ssss);
foreach (Match match in matchList) {
returnList.Add(match.Groups["cell"].Value);
}
string[] str = strphone.Split('、');
foreach (string s in str)
{
string s1 = s.Length > 11 ?s.Substring(0,11):s;
if (s1.Length == 11)
{
string sphone = s1.Substring(0, 1);
if ( sphone== "1")
{
MessageBox.Show(s1);
//s这个条件成立,s就是你要的手机号码
}
}
}
string ssss = @"13911178654、62913474、13683119915\68744532、13802880518";
ArrayList returnList = new ArrayList();
string pattern = @"(?<cell>\d{11})";
Regex regex = new Regex(pattern);
MatchCollection matchList = regex.Matches(ssss);
foreach (Match match in matchList) {
MessageBox.Show(match.Groups["cell"].Value);
}
for (int i = 0; i < 100000; i++)
{
string ssss = @"13911178654、62913474、13683119915\68744532、13802880518";
ArrayList returnList = new ArrayList();
string pattern = @"(?<cell>\d{11})";
Regex regex = new Regex(pattern);
MatchCollection matchList = regex.Matches(ssss);
foreach (Match match in matchList)
{
//MessageBox.Show(match.Groups["cell"].Value);
}
}
这个正则的比较慢,而以下的速度非常快,不信你可以自己测试
for (int i = 0; i < 100000; i++)
{
string strphone = @"13911178654、62913474、13683119915\68744532、13802880518";
string[] str = strphone.Split('、');
foreach (string s in str)
{
string s1 = s.Length > 11 ? s.Substring(0, 11) : s;
if (s1.Length == 11)
{
string sphone = s1.Substring(0, 1);
if (sphone == "1")
{
//MessageBox.Show(s1);
//s这个条件成立,s就是你要的手机号码
}
}
}
}