RegexMatch
Struct · namespace System · Since 0.21
struct RegexMatchA match of a Regex: where it is, its text and the text of its groups.
Fields
Section titled “Fields”| Name | Description |
|---|---|
Index |
The position of the match in the text (bytes). |
Length |
The length of the match (bytes). |
Value |
The matched text. |
Text |
The text that was searched. |
Captures |
The start and end of every group (-1: it did not take part), group 0 (the whole match) first. |
GroupNames |
The names of the groups ("" for unnamed ones), group 0 first. |
int IndexThe position of the match in the text (bytes).
Length
Section titled “Length”int LengthThe length of the match (bytes).
string ValueThe matched text.
string TextThe text that was searched.
Captures
Section titled “Captures”int[] CapturesThe start and end of every group (-1: it did not take part), group 0 (the whole match) first.
GroupNames
Section titled “GroupNames”string[] GroupNamesThe names of the groups ("" for unnamed ones), group 0 first.
Methods
Section titled “Methods”| Name | Description |
|---|---|
GroupCount |
The number of groups of the pattern (without group 0, the whole match). |
Group |
The text of group n (0: the whole match). |
GroupNumber |
The number of the group (?<name>...). |
GroupMatched |
Whether group n took part in the match (not: an alternative that was not taken, x? without x). |
GroupIndex |
The position of group n in the text (bytes). |
GroupCount
Section titled “GroupCount”int GroupCount()The number of groups of the pattern (without group 0, the whole match).
string Group(int n)The text of group n (0: the whole match).
Returns "" if the group did not take part in the match.
Panics when the pattern has no group n.
string Group(string name)The text of the group (?<name>...).
Returns "" if the group did not take part in the match.
Panics when the pattern has no group of that name.
GroupNumber
Section titled “GroupNumber”int GroupNumber(string name)The number of the group (?<name>...).
Panics when the pattern has no group of that name.
GroupMatched
Section titled “GroupMatched”bool GroupMatched(int n)Whether group n took part in the match (not: an alternative that was not taken, x? without x).
GroupIndex
Section titled “GroupIndex”int GroupIndex(int n)The position of group n in the text (bytes).
Returns -1 if the group did not take part in the match.