Skip to Main Content
C# in a Nutshell, Second Edition
book

C# in a Nutshell, Second Edition

by Peter Drayton, Ben Albahari, Ted Neward
August 2003
Intermediate to advanced content levelIntermediate to advanced
928 pages
32h 1m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell, Second Edition

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(Match inner);
// Public Instance Methods
   public Match NextMatch( );
   public virtual string Result(string replacement);
}

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.
Start your free trial

You might also like

C# in a Nutshell

C# in a Nutshell

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

C# 7.0 in a Nutshell

Joseph Albahari, Ben Albahari
C# Cookbook, 2nd Edition

C# Cookbook, 2nd Edition

Jay Hilyard, Stephen Teilhet
C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard

Publisher Resources

ISBN: 0596005261Catalog PageErrata