62,046
社区成员
发帖
与我相关
我的任务
分享
a.a.a.a.a.a.com
b.b.b.com
c.com
d.d.d.d.d.d.d.d.d.d.d.com
a.com
b.com
c.com
d.com
foreach (Match item in s1)
{
Console.WriteLine(item.Groups["name"]);
}
MatchCollection s1 = Regex.Matches(s, @"\w+.\w+.(?<name>\w+.(org|cn|dd))");
aaa.com.net.org
b.net.org.cn
c.org.cn.dd
提取出
net.org
org.cn
cn.dd
就是取最后的xxxx.xxxx
谢谢!namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string s = @"a.a.a.a.a.a.com
b.b.b.com
c.com
d.d.d.d.d.d.d.d.d.d.d.com";
MatchCollection s1 = Regex.Matches(s, @"\w{1}.com");
foreach (var item in s1)
{
Console.WriteLine(item);
}
}
}
}