summaryrefslogtreecommitdiff
path: root/doc/base/classes.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/base/classes.xml')
-rw-r--r--doc/base/classes.xml122
1 files changed, 101 insertions, 21 deletions
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index 5eb021f6c0..47fa1deb55 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -32514,6 +32514,7 @@
would be read as [code]"(?:\\.|[^"])*"[/code]
Currently supported features:
* Capturing [code]()[/code] and non-capturing [code](?:)[/code] groups
+ * Named capturing groups [code](?P<name>)[/code]
* Any character [code].[/code]
* Shorthand character classes [code]\w \W \s \S \d \D[/code]
* User-defined character classes such as [code][A-Za-z][/code]
@@ -32522,7 +32523,7 @@
* Lazy (non-greedy) quantifiers [code]*?[/code]
* Beginning [code]^[/code] and end [code]$[/code] anchors
* Alternation [code]|[/code]
- * Backreferences [code]\1[/code] and [code]\g{1}[/code]
+ * Backreferences [code]\1[/code], [code]\g{1}[/code], and [code]\g<name>[/code]
* POSIX character classes [code][[:alnum:]][/code]
* Lookahead [code](?=)[/code], [code](?!)[/code] and lookbehind [code](?<=)[/code], [code](?<!)[/code]
* ASCII [code]\xFF[/code] and Unicode [code]\uFFFF[/code] code points (in a style similar to Python)
@@ -32531,7 +32532,7 @@
<methods>
<method name="clear">
<description>
- This method resets the state of the object, as it was freshly created. Namely, it unassigns the regular expression of this object, and forgets all captures made by the last [method find].
+ This method resets the state of the object, as it was freshly created. Namely, it unassigns the regular expression of this object.
</description>
</method>
<method name="compile">
@@ -32539,15 +32540,41 @@
</return>
<argument index="0" name="pattern" type="String">
</argument>
- <argument index="1" name="capture" type="int" default="9">
- </argument>
<description>
- Compiles and assign the regular expression pattern to use. The limit on the number of capturing groups can be specified or made unlimited if negative.
+ Compiles and assign the regular expression pattern to use.
</description>
</method>
- <method name="find" qualifiers="const">
+ <method name="get_group_count" qualifiers="const">
<return type="int">
</return>
+ <description>
+ Returns the number of numeric capturing groups.
+ </description>
+ </method>
+ <method name="get_names" qualifiers="const">
+ <return type="Array">
+ </return>
+ <description>
+ Returns an array of names of named capturing groups.
+ </description>
+ </method>
+ <method name="get_pattern" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ Returns the expression used to compile the code.
+ </description>
+ </method>
+ <method name="is_valid" qualifiers="const">
+ <return type="bool">
+ </return>
+ <description>
+ Returns whether this object has a valid regular expression assigned.
+ </description>
+ </method>
+ <method name="search" qualifiers="const">
+ <return type="Object">
+ </return>
<argument index="0" name="text" type="String">
</argument>
<argument index="1" name="start" type="int" default="0">
@@ -32555,45 +32582,98 @@
<argument index="2" name="end" type="int" default="-1">
</argument>
<description>
- This method tries to find the pattern within the string, and returns the position where it was found. It also stores any capturing group (see [method get_capture]) for further retrieval.
+ Searches the text for the compiled pattern. Returns a [RegExMatch] container of the first matching reult if found, otherwise null. The region to search within can be specified without modifying where the start and end anchor would be.
</description>
</method>
- <method name="get_capture" qualifiers="const">
+ <method name="sub" qualifiers="const">
<return type="String">
</return>
- <argument index="0" name="capture" type="int">
+ <argument index="0" name="text" type="String">
+ </argument>
+ <argument index="1" name="replacement" type="String">
+ </argument>
+ <argument index="2" name="all" type="bool" default="false">
+ </argument>
+ <argument index="3" name="start" type="int" default="0">
+ </argument>
+ <argument index="4" name="end" type="int" default="-1">
</argument>
<description>
- Returns a captured group. A captured group is the part of a string that matches a part of the pattern delimited by parentheses (unless they are non-capturing parentheses [i](?:)[/i]).
+ Searches the text for the compiled pattern and replaces it with the specified string. Escapes and backreferences such as [code]\1[/code] and [code]\g&lt;name&gt;[/code] expanded and resolved. By default only the first instance is replaced but it can be changed for all instances (global replacement). The region to search within can be specified without modifying where the start and end anchor would be.
</description>
</method>
- <method name="get_capture_count" qualifiers="const">
- <return type="int">
+ </methods>
+ <constants>
+ </constants>
+</class>
+<class name="RegExMatch" inherits="Reference" category="Core">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <methods>
+ <method name="expand" qualifiers="const">
+ <return type="String">
</return>
+ <argument index="0" name="template" type="String">
+ </argument>
<description>
- Returns the number of capturing groups. A captured group is the part of a string that matches a part of the pattern delimited by parentheses (unless they are non-capturing parentheses [i](?:)[/i]).
+ Using results from the search, returns the specified string with escapes and backreferences such as [code]\1[/code] and [code]\g&lt;name&gt;[/code] expanded and resolved.
</description>
</method>
- <method name="get_capture_start" qualifiers="const">
+ <method name="get_end" qualifiers="const">
<return type="int">
</return>
- <argument index="0" name="capture" type="int">
+ <argument index="0" name="name" type="Variant" default="0">
</argument>
<description>
+ Returns the end position of the match in the string. An interger can be specified for numeric groups or a string for named groups. Returns -1 if that group wasn't found or doesn't exist. Defaults to 0 (whole pattern).
</description>
</method>
- <method name="get_captures" qualifiers="const">
- <return type="StringArray">
+ <method name="get_group_array" qualifiers="const">
+ <return type="Array">
</return>
<description>
- Return a list of all the captures made by the regular expression.
+ Returns an array of the results of the numeric groups.
</description>
</method>
- <method name="is_valid" qualifiers="const">
- <return type="bool">
+ <method name="get_group_count" qualifiers="const">
+ <return type="int">
</return>
<description>
- Returns whether this object has a valid regular expression assigned.
+ Returns the number of numeric capturing groups.
+ </description>
+ </method>
+ <method name="get_name_dict" qualifiers="const">
+ <return type="Dictionary">
+ </return>
+ <description>
+ Returns a dictionary containing the named capturing groups and their results.
+ </description>
+ </method>
+ <method name="get_names" qualifiers="const">
+ <return type="Array">
+ </return>
+ <description>
+ Returns an array of names of named capturing groups.
+ </description>
+ </method>
+ <method name="get_start" qualifiers="const">
+ <return type="int">
+ </return>
+ <argument index="0" name="name" type="Variant" default="0">
+ </argument>
+ <description>
+ Returns the starting position of the match in the string. An interger can be specified for numeric groups or a string for named groups. Returns -1 if that group wasn't found or doesn't exist. Defaults to 0 (whole pattern).
+ </description>
+ </method>
+ <method name="get_string" qualifiers="const">
+ <return type="String">
+ </return>
+ <argument index="0" name="name" type="Variant" default="0">
+ </argument>
+ <description>
+ Returns the result of the match in the string. An interger can be specified for numeric groups or a string for named groups. Returns -1 if that group wasn't found or doesn't exist. Defaults to 0 (whole pattern).
</description>
</method>
</methods>