62,074
社区成员
发帖
与我相关
我的任务
分享
public static void GetA6()
{
string str1 = "13552136014";
Regex regex1=new Regex("^135\\d{8}$");
Console.WriteLine(regex1.IsMatch(str1));
string str2 = "0731-04421002";
Regex regex2 = new Regex("^\\d{4}-\\d{8}$");
Console.WriteLine(regex2.IsMatch(str2));
string str3 = "0731-04421003,13552136014";
Regex regex3 = new Regex(@"^(135\d{8},\d{4}-\d{8})|(\d{4}-\d{8},135\d{8})$");
Console.WriteLine(regex3.IsMatch(str3));
}
List<string> temp_list = new List<string> {
"13512341234",
"0538-38773588",
"13512341234,0538-38773588",
"0538-38773588,13512341234",
"0010-0122458542,12asd721457"
};
string pattern = @"^((\d{11}|\d{4}-\d{8})[,,]?)+$";
foreach (string str in temp_list)
{
if (Regex.IsMatch(str, pattern))
{
//匹配前四个,第四个无法匹配
}
}
string pattern = @"((\d{11}|\d{4}-\d{8})[,,]?)+";