Regex class

Regex.Match searches within a larger string.

The object that it returns has properties for the Index and Length of the match, as well as the actual Value matched:


using System;
using System.Text.RegularExpressions;


class Program
{
    static void Main(string[] args)
    {
        Match m = Regex.Match("abcd", @"abcd?e");

        Console.WriteLine(m.Success); 
        Console.WriteLine(m.Index); 
        Console.WriteLine(m.Length);  
        Console.WriteLine(m.Value); 
        Console.WriteLine(m.ToString());  
    }
}

The output:


False
0
0
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.