using System;
using System.Net;
using System.Text.RegularExpressions;
using System.IO;
class TestMatchGroups
{
public static void Main()
{
//一部
Console.WriteLine(Regex.Match(@"Tell me who you are\Radys$1982#06", @".*\\(.*?)$").Groups[1]);
//两部分
Console.WriteLine("My name is:{0},and my year is:{1}",
Regex.Match(@"Tell me who you are\Radys$1982#06", @".*\\(?<myname>.*?)(?<year>\$.*?)").Groups["myname"],
Regex.Match(@"Tell me who you are\Radys$1982#06", @".*\\(?<myname>.*?)\$(?<year>.*?)$").Groups["year"]
);
//三个
Console.WriteLine("My name is:{0},and my year is:{1},the month is:{2}",
Regex.Match(@"Tell me who you are\Radys$1982#06", @".*\\(?<myname>.*?)(?<year>\$.*?)").Groups["myname"],
Regex.Match(@"Tell me who you are\Radys$1982#06", @".*\\(?<myname>.*?)\$(?<year>.*?)$").Groups["year"],
Regex.Match(@"Tell me who you are\Radys$1982#06", @".*\\(?<myname>.*?)\$(?<year>.*?)#(?<month>.*?)$").Groups["month"]
);
}
}
浙公网安备 33010602011771号