111,125
社区成员
发帖
与我相关
我的任务
分享 static void Main(string[] args)
{
string test = "a b c";
Regex Re = new Regex("(a|b|c)");
MatchCollection mc = Re.Matches(test);
foreach (Match m in mc)
{
Console.WriteLine(" 这个m 是 " + m.Value.ToString() + " 部分匹配的");
}
}
Regex Re = new Regex("(?:(a)|(b)|(c))");
MatchCollection mc = Re.Matches(input);
foreach(Match m in mc)
{
m.Groups[1].Value // 正则表达式 a 匹配的部分
m.Groups[2].Value // 正则表达式 b 匹配的部分
m.Groups[3].Value // 正则表达式 c 匹配的部分
}