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 Match Empty{get; } // Public Instance Properties public virtual GroupCollection Groups{get; } // Public Static Methods public static Match Synchronized(Matchinner); // Public Instance Methods public Match NextMatch( ); public virtual string Result(stringreplacement); }
Hierarchy
System.Object
→
Capture
→
Group
→
Match
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access