final class · System.Text
Match
public final class Match
A match: where it is, its text, and its groups (an unmatched group gives the empty text).
- Kind
- final class
- Namespace
- System.Text
- Assembly
- System.Core
- Access
- public, final
- Source file
Regex.ant
Inheritance
- Base classes
-
AnyMatch
Constructors
Properties
Methods
The text between two positions.
Group i (1-based; 0 is the whole match).
Fields
Inherited members (5)
GetTypemethod from AnyUndescribedmethod from AnyToStringmethod from AnyHashmethod from Anydestroymethod from Any
Source
Match as Antril, decompiled from its Larva HIR.
// System.Text.Match — System.Core (decompiled from Larva HIR)
import System;
into namespace System.Text
{
/// A match: where it is, its text, and its groups (an unmatched group gives the empty text).
public final class Match
{
u8[] s;
i32[] starts;
i32[] ends;
public:
bool Success;
i32 Index;
i32 Length;
str Value;
/// The text between two positions.
static Slice(u8[] s, i32 from, i32 to) : str
{
u8[] bytes = new u8[to - from];
Array.Copy(s, from, bytes, 0, to - from);
return new str(bytes);
}
new(u8[] text, i32[] groupStarts, i32[] groupEnds, i32 index, i32 end)
{
s = text;
starts = groupStarts;
ends = groupEnds;
Success = index >= 0;
Index = index;
Length = Success ? end - index : 0;
Value = Success ? Slice(text, index, end) : "";
}
/// Group `i` (1-based; 0 is the whole match).
Group(i32 i) : str
{
if (i == 0)
return Value;
if (i < 0 || i >= starts.Length || starts[i] < 0 || ends[i] < 0)
return "";
return Slice(s, starts[i], ends[i]);
}
i32 GroupCount
{
get => starts.Length - 1;
}
}
}