62,025
社区成员
发帖
与我相关
我的任务
分享
public string getPhone(string str)
{
try
{
string _str;
Regex Expression = new Regex("13[0-9]{9}|15[0-9]{9}");
MatchCollection match = Expression.Matches(str);
foreach (Match m in match)
{
_str+= m.Value+",";
}
return _str;
}
catch (Exception ex)
{
return ex.Message;
}
}
string str=getPhone(strDianHua);
string [] phones=str.Trim(',').Split(',');
using System;
using System.Net;
using System.Collections.Generic;
using System.Xml;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication13
{
class Program
{
static void Main(string[] args)
{
try
{
string _str = string.Empty;
string str = "1391235467815845678954";
Regex Expression = new Regex("13[0-9]{9}|15[0-9]{9}");
MatchCollection match = Expression.Matches(str);
foreach (Match m in match)
{
_str = m.Value;
}
Console.WriteLine(_str);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
/*
* 15845678954
*/
完全可以啊。。。