111,125
社区成员
发帖
与我相关
我的任务
分享string str = "asiatelecom_10.209.8.11_20100106545454AT9052";
Regex r = new Regex("asiatelecom_\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}_(\\d{14})(\\w{6})$");
Console.WriteLine(r.Match(str).Value);
Console.WriteLine(r.Match(str).Groups[1].Value);//可以匹配到 第一个()里的 \\d{14} 结果是 20100106545454
Console.WriteLine(r.Match(str).Groups[2].Value);//可以匹配到 第一个()里的 \\w{6} 结果是 AT9052
Console.Read();static void Main(string[] args)
{
string str = "asiatelecom_10.209.8.11_20100106545454_AT9052";
Regex r = new Regex("asiatelecom_\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}_(\\d{14})_(\\w{6})$");
Console.WriteLine(r.Match(str).Value);
Console.WriteLine(r.Match(str).Groups[1].Value);//可以匹配到 第一个()里的 \\d{14} 结果是 20100106545454
Console.WriteLine(r.Match(str).Groups[2].Value);//可以匹配到 第一个()里的 \\w{6} 结果是 AT9052
Console.Read();
}Regex r = new Regex("asiatelecom_\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}_(\\d{14}) (\\w{6})$");