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).
- Tipo
- final class
- Espacio de nombres
- System.Text
- Ensamblado
- System.Core
- Acceso
- public, final
- Archivo fuente
Regex.ant
Herencia
- Clases base
-
AnyMatch
Constructores
Propiedades
Métodos
The text between two positions.
Group i (1-based; 0 is the whole match).
Campos
Miembros heredados (5)
GetTypemétodo de AnyUndescribedmétodo de AnyToStringmétodo de AnyHashmétodo de Anydestroymétodo de Any
Código fuente
Match en Antril, descompilado a partir de su 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;
}
}
}