summaryrefslogtreecommitdiff
path: root/modules/regex/doc_classes
diff options
context:
space:
mode:
Diffstat (limited to 'modules/regex/doc_classes')
-rw-r--r--modules/regex/doc_classes/RegEx.xml46
-rw-r--r--modules/regex/doc_classes/RegExMatch.xml8
2 files changed, 32 insertions, 22 deletions
diff --git a/modules/regex/doc_classes/RegEx.xml b/modules/regex/doc_classes/RegEx.xml
index deabc5ccd3..02260c837e 100644
--- a/modules/regex/doc_classes/RegEx.xml
+++ b/modules/regex/doc_classes/RegEx.xml
@@ -4,7 +4,7 @@
Class for searching text for patterns using regular expressions.
</brief_description>
<description>
- A regular expression (or regex) is a compact language that can be used to recognise strings that follow a specific pattern, such as URLs, email addresses, complete sentences, etc. For instance, a regex of [code]ab[0-9][/code] would find any string that is [code]ab[/code] followed by any number from [code]0[/code] to [code]9[/code]. For a more in-depth look, you can easily find various tutorials and detailed explanations on the Internet.
+ A regular expression (or regex) is a compact language that can be used to recognize strings that follow a specific pattern, such as URLs, email addresses, complete sentences, etc. For example, a regex of [code]ab[0-9][/code] would find any string that is [code]ab[/code] followed by any number from [code]0[/code] to [code]9[/code]. For a more in-depth look, you can easily find various tutorials and detailed explanations on the Internet.
To begin, the RegEx object needs to be compiled with the search pattern using [method compile] before it can be used.
[codeblock]
var regex = RegEx.new()
@@ -57,11 +57,18 @@
</method>
<method name="compile">
<return type="int" enum="Error" />
- <argument index="0" name="pattern" type="String" />
+ <param index="0" name="pattern" type="String" />
<description>
Compiles and assign the search pattern to use. Returns [constant OK] if the compilation is successful. If an error is encountered, details are printed to standard output and an error is returned.
</description>
</method>
+ <method name="create_from_string" qualifiers="static">
+ <return type="RegEx" />
+ <param index="0" name="pattern" type="String" />
+ <description>
+ Creates and compiles a new [RegEx] object.
+ </description>
+ </method>
<method name="get_group_count" qualifiers="const">
<return type="int" />
<description>
@@ -69,7 +76,7 @@
</description>
</method>
<method name="get_names" qualifiers="const">
- <return type="Array" />
+ <return type="PackedStringArray" />
<description>
Returns an array of names of named capturing groups in the compiled pattern. They are ordered by appearance.
</description>
@@ -88,31 +95,34 @@
</method>
<method name="search" qualifiers="const">
<return type="RegExMatch" />
- <argument index="0" name="subject" type="String" />
- <argument index="1" name="offset" type="int" default="0" />
- <argument index="2" name="end" type="int" default="-1" />
+ <param index="0" name="subject" type="String" />
+ <param index="1" name="offset" type="int" default="0" />
+ <param index="2" name="end" type="int" default="-1" />
<description>
- Searches the text for the compiled pattern. Returns a [RegExMatch] container of the first matching result if found, otherwise [code]null[/code]. The region to search within can be specified without modifying where the start and end anchor would be.
+ Searches the text for the compiled pattern. Returns a [RegExMatch] container of the first matching result if found, otherwise [code]null[/code].
+ The region to search within can be specified with [param offset] and [param end]. This is useful when searching for another match in the same [param subject] by calling this method again after a previous success. Note that setting these parameters differs from passing over a shortened string. For example, the start anchor [code]^[/code] is not affected by [param offset], and the character before [param offset] will be checked for the word boundary [code]\b[/code].
</description>
</method>
<method name="search_all" qualifiers="const">
- <return type="Array" />
- <argument index="0" name="subject" type="String" />
- <argument index="1" name="offset" type="int" default="0" />
- <argument index="2" name="end" type="int" default="-1" />
+ <return type="RegExMatch[]" />
+ <param index="0" name="subject" type="String" />
+ <param index="1" name="offset" type="int" default="0" />
+ <param index="2" name="end" type="int" default="-1" />
<description>
- Searches the text for the compiled pattern. Returns an array of [RegExMatch] containers for each non-overlapping result. If no results were found, an empty array is returned instead. The region to search within can be specified without modifying where the start and end anchor would be.
+ Searches the text for the compiled pattern. Returns an array of [RegExMatch] containers for each non-overlapping result. If no results were found, an empty array is returned instead.
+ The region to search within can be specified with [param offset] and [param end]. This is useful when searching for another match in the same [param subject] by calling this method again after a previous success. Note that setting these parameters differs from passing over a shortened string. For example, the start anchor [code]^[/code] is not affected by [param offset], and the character before [param offset] will be checked for the word boundary [code]\b[/code].
</description>
</method>
<method name="sub" qualifiers="const">
<return type="String" />
- <argument index="0" name="subject" type="String" />
- <argument index="1" name="replacement" type="String" />
- <argument index="2" name="all" type="bool" default="false" />
- <argument index="3" name="offset" type="int" default="0" />
- <argument index="4" name="end" type="int" default="-1" />
+ <param index="0" name="subject" type="String" />
+ <param index="1" name="replacement" type="String" />
+ <param index="2" name="all" type="bool" default="false" />
+ <param index="3" name="offset" type="int" default="0" />
+ <param index="4" name="end" type="int" default="-1" />
<description>
- Searches the text for the compiled pattern and replaces it with the specified string. Escapes and backreferences such as [code]$1[/code] and [code]$name[/code] are 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.
+ Searches the text for the compiled pattern and replaces it with the specified string. Escapes and backreferences such as [code]$1[/code] and [code]$name[/code] are 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 with [param offset] and [param end]. This is useful when searching for another match in the same [param subject] by calling this method again after a previous success. Note that setting these parameters differs from passing over a shortened string. For example, the start anchor [code]^[/code] is not affected by [param offset], and the character before [param offset] will be checked for the word boundary [code]\b[/code].
</description>
</method>
</methods>
diff --git a/modules/regex/doc_classes/RegExMatch.xml b/modules/regex/doc_classes/RegExMatch.xml
index 530a541ae8..31e2207d84 100644
--- a/modules/regex/doc_classes/RegExMatch.xml
+++ b/modules/regex/doc_classes/RegExMatch.xml
@@ -11,7 +11,7 @@
<methods>
<method name="get_end" qualifiers="const">
<return type="int" />
- <argument index="0" name="name" type="Variant" default="0" />
+ <param index="0" name="name" type="Variant" default="0" />
<description>
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.
@@ -25,7 +25,7 @@
</method>
<method name="get_start" qualifiers="const">
<return type="int" />
- <argument index="0" name="name" type="Variant" default="0" />
+ <param index="0" name="name" type="Variant" default="0" />
<description>
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.
@@ -33,7 +33,7 @@
</method>
<method name="get_string" qualifiers="const">
<return type="String" />
- <argument index="0" name="name" type="Variant" default="0" />
+ <param index="0" name="name" type="Variant" default="0" />
<description>
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.
@@ -44,7 +44,7 @@
<member name="names" type="Dictionary" setter="" getter="get_names" default="{}">
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.
</member>
- <member name="strings" type="Array" setter="" getter="get_strings" default="[]">
+ <member name="strings" type="PackedStringArray" setter="" getter="get_strings" default="PackedStringArray()">
An [Array] of the match and its capturing groups.
</member>
<member name="subject" type="String" setter="" getter="get_subject" default="&quot;&quot;">