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
Any Match

Constructores

new(u8[] text, i32[] groupStarts, i32[] groupEnds, i32 index, i32 end)
#

Propiedades

i32 GroupCount { get; }
#

read-only

Métodos

static Slice(u8[] s, i32 from, i32 to) : str
#

static

The text between two positions.

Group(i32 i) : str
#

Group i (1-based; 0 is the whole match).

Campos

bool Success
#
i32 Index
#
i32 Length
#
str Value
#

Miembros privados e internos (3)

u8[] s
#

private

i32[] starts
#

private

i32[] ends
#

private

Miembros heredados (5)

Código fuente

Match en Antril, descompilado a partir de su Larva HIR.

System.Text.Match.ant
// 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;
			}
	}
}
Esc