Define groups 'ing', 'in', 'n' : Regular Expression : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » Regular Expression »

 

Define groups 'ing', 'in', 'n'








    
 


using System;
using System.Text.RegularExpressions;

class GroupingApp {
    static void Main(string[] args) {
        Regex r = new Regex("(i(n))g");
        Match m = r.Match("Matching");
        GroupCollection gc = m.Groups;
        Console.WriteLine("Found {0} Groups", gc.Count);
        for (int i = 0; i < gc.Count; i++) {
            Group g = gc[i];
            Console.WriteLine("Found '{0}' at position {1}",g.Value, g.Index);
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» Regular Expression