Match Group Value : Regex Group « Regular Expression « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using System.Reflection;

public class MainClass{

   public static void Main(){
        Regex r = new Regex(@"<([^>]+)>([^<]*)</(\1)>");
        Match m = r.Match("<M>S</M>");
        Console.WriteLine("Tag: {0}, InnerText: {1}", m.Groups[1].Value, m.Groups[2].Value);
   }
}
Tag: M, InnerText: S








17.4.Regex Group
17.4.1.Match Group Value
17.4.2.Get Group in a match
17.4.3.Name a Regex group
17.4.4.RegEx Group
17.4.5.Get named group from Match