diff options
author | Zher Huei Lee <lee.zh.92@gmail.com> | 2016-10-23 01:22:48 +0100 |
---|---|---|
committer | Zher Huei Lee <lee.zh.92@gmail.com> | 2016-10-27 10:27:40 +0100 |
commit | 439d43932133d32dcabd482f11842072d52b41e1 (patch) | |
tree | a3df1a0366b25a845d337836b3e163a6ffc72fec /doc/base/classes.xml | |
parent | 470ead74dbc3d6ea7133ab90c0d09ed637e7a5f5 (diff) |
RegEx re-implemented as a module
Re-wrote nrex as a module using godot-specific parts and new
features:
* Added string substitutions.
* Named groups are now supported.
* Removed use of mutable variables in RegEx. RegExMatch is returned
instead.
Diffstat (limited to 'doc/base/classes.xml')
-rw-r--r-- | doc/base/classes.xml | 120 |
1 files changed, 99 insertions, 21 deletions
diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 5eb021f6c0..cafb144915 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,96 @@ <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 starting point of the serch could be specified without moving the string start anchor. </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="template" type="String"> + </argument> + <argument index="2" name="start" type="int" default="0"> + </argument> + <argument index="3" 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 specified text for the compiled pattern and returns the text with the result replaced. Escapes and backreferences such as [code]\1[/code] and [code]\g<name>[/code] are automatically expanded and resolved. If no change was found the unmodified text is returned instead. </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<name>[/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> |