XML technologies / Regular expressions / .NET / Objects in detail / Using Group objects
(Excerpt from "Regular expressions" by Jeffrey E. F. Friedl)
A Group object holds all match data for a particular capturing group, or the whole match for group zero. It has the following properties and methods:
GroupObj.Success
Returns a Boolean indicating whether the group participated in the match. A parenthesized expression in a regex need not participate in the overall match. For example, when ˹(klipp)|(klar)˼ matches, only one group actually participates and the other does not. Another example appears in the note under Alternation.
GroupObj.Value
GroupObj.ToString()
Both return the text captured by the corresponding group, or an empty string on failure.
GroupObj.Length
Returns the length of the text captured by this group, or zero on failure.
GroupObj.Index
Returns the start of the captured text within the input string as an integer. Characters are counted from zero, so this is the number of characters before the captured text. This remains true when option RegexOptions.RightToLeft is used.
GroupObj.Captures
The Group object also has a Captures property; see Capture objects.
German edition copyright © 2008 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for private use.
Otherwise, this chapter from "Reguläre Ausdrücke" is subject to the same terms as the bound edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln
back to top