Table of Contents

Class RegExMatch

Namespace
Godot
Assembly
GodotSharp.dll

Contains the results of a single RegEx match returned by Search(string, int, int) and SearchAll(string, int, int). It can be used to find the position and range of the match and its capturing groups, and it can extract its substring for you.

public class RegExMatch : RefCounted, IDisposable
Inheritance
RegExMatch
Implements
Inherited Members

Constructors

RegExMatch()

public RegExMatch()

Properties

Names

A dictionary of named groups and its corresponding group number. Only groups that were matched are included. If multiple groups have the same name, that name would refer to the first matching one.

public Dictionary Names { get; }

Property Value

Dictionary

Strings

An Array of the match and its capturing groups.

public string[] Strings { get; }

Property Value

string[]

Subject

The source string used with the search pattern to find this matching result.

public string Subject { get; }

Property Value

string

Methods

GetEnd(Variant?)

Returns the end position of the match within the source string. The end position of capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern.

Returns -1 if the group did not match or doesn't exist.

public int GetEnd(Variant? name = null)

Parameters

name Variant?

If the parameter is null, then the default value is (Variant)(0).

Returns

int

GetGroupCount()

Returns the number of capturing groups.

public int GetGroupCount()

Returns

int

GetStart(Variant?)

Returns the starting position of the match within the source string. The starting position of capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern.

Returns -1 if the group did not match or doesn't exist.

public int GetStart(Variant? name = null)

Parameters

name Variant?

If the parameter is null, then the default value is (Variant)(0).

Returns

int

GetString(Variant?)

Returns the substring of the match from the source string. Capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern.

Returns an empty string if the group did not match or doesn't exist.

public string GetString(Variant? name = null)

Parameters

name Variant?

If the parameter is null, then the default value is (Variant)(0).

Returns

string

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool