我有一个像这样的正则表达式
something (.*) someotherthing
如何使用 Regex 对象来匹配整个表达式并获取捕获的值?
请您参考如下方法:
这是我认为您要求的示例:
Match m = Regex.Match( "something some stuff in the middle someotherthing",
"something (.*) someotherthing" );
if ( m.Success )
Console.WriteLine( "groups={0}, entire match={1}, first group={2}",
m.Groups.Count, m.Groups[0].Value,
m.Groups[1].Value );
