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 ...

Get C# in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.