RegExMatch

继承: RefCounted < Object

Contains the results of a RegEx search.

描述

Contains the results of a single RegEx match returned by RegEx.search and RegEx.search_all. 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.

属性

方法

intget_end ( name: Variant = 0 ) const1
intget_group_count ( ) const1
intget_start ( name: Variant = 0 ) const1
Stringget_string ( name: Variant = 0 ) const1

属性说明

Dictionary 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.


PackedStringArray strings = PackedStringArray()

An Array of the match and its capturing groups.

Note: The returned array is copied and any changes to it will not update the original property value. See PackedStringArray for more details.


String subject = ""

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


方法说明

int get_end ( name: Variant = 0 ) const1

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.


int get_group_count ( ) const1

Returns the number of capturing groups.


int get_start ( name: Variant = 0 ) const1

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.


String get_string ( name: Variant = 0 ) const1

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.

2

本方法通常需要用户覆盖才能生效。

1

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。