O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Match

Synopsis

This class is a single match result of a regular expression. As with Capture and Group, Match has no public constructor. It is returned by Regex.Match() or as a member of a MatchCollection returned by Regex.Matches(). A Match instance contains the groups that have been captured in a GroupCollection returned by Groups. A Match inherits from Group and is equivalent to the zero-indexed group in its GroupCollection (the same as Groups [0]).

The NextMatch() method finds the next match result in the search string, starting at the end of the previous match. This method disregards any zero-width assertions on the tail of an expression and begins explicitly after the position of the last character of the previous result (even an empty result).

The Result() method takes a replacement pattern and returns the resulting string based on the current match. A replacement pattern is an expression that uses the group replacement syntax, such as $1 or ${name}. Result() expands the replacement variables corresponding to the captured groups, within its current result, and returns the string.

public class Match : Group {
// Public Static Properties
   public static field Match Empty{get; } 
// Public Instance Properties
   public virtual field GroupCollection Groups{get; } 
// Public Static Methods
   public static method Match Synchronized(Match inner);  
// Public Instance Methods
   public method Match NextMatch();  
   public virtual method string Result(string replacement);  
}

Hierarchy

System.Object ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required