Match class

The regular expressions engine works from left to right by default, so only the left-most match is returned.

You can use the NextMatch method to return more matches:


using System;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        Match m1 = Regex.Match("This is a test from java2s.com", @"2?s?");
        Match m2 = m1.NextMatch();
        Console.WriteLine(m1);  
        Console.WriteLine(m2);  
    }
}
w___ww_.j_a_va2_s.___c_o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.