summaryrefslogtreecommitdiff
path: root/modules/regex
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2019-06-22 01:04:47 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2019-06-27 22:30:19 +0200
commitf7f6115f7627df24a08a9a0882b2f573cc838eb1 (patch)
tree03fd75145084c88702dbbb7e54c42c7c02d54fa6 /modules/regex
parent538c8eec15d72b67e102f47f9df7624c29d14607 (diff)
Proofread and improve the whole class reference
- Document a few more properties and methods - Add more information to many classes - Fix lots of typos and gramar mistakes - Use [code] tags for parameters consistently - Use [b] and [i] tags consistently - Put "Warning:" and "Note:" on their own line to be more visible, and make them always bold - Tweak formatting in code examples to be more readable - Use double quotes consistently - Add more links to third-party technologies
Diffstat (limited to 'modules/regex')
-rw-r--r--modules/regex/doc_classes/RegEx.xml16
-rw-r--r--modules/regex/doc_classes/RegExMatch.xml4
2 files changed, 10 insertions, 10 deletions
diff --git a/modules/regex/doc_classes/RegEx.xml b/modules/regex/doc_classes/RegEx.xml
index cc8205e400..74b06039d4 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>
- Regular Expression (or regex) is a compact programming 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 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.
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()
@@ -19,7 +19,7 @@
if result:
print(result.get_string()) # Would print n-0123
[/codeblock]
- The results of capturing groups [code]()[/code] can be retrieved by passing the group number to the various functions in [RegExMatch]. Group 0 is the default and would always refer to the entire pattern. In the above example, calling [code]result.get_string(1)[/code] would give you [code]0123[/code].
+ The results of capturing groups [code]()[/code] can be retrieved by passing the group number to the various functions in [RegExMatch]. Group 0 is the default and will always refer to the entire pattern. In the above example, calling [code]result.get_string(1)[/code] would give you [code]0123[/code].
This version of RegEx also supports named capturing groups, and the names can be used to retrieve the results. If two or more groups have the same name, the name would only refer to the first one with a match.
[codeblock]
var regex = RegEx.new()
@@ -28,7 +28,7 @@
if result:
print(result.get_string("digit")) # Would print 2f
[/codeblock]
- If you need to process multiple results, [method search_all] generates a list of all non-overlapping results. This can be combined with a for-loop for convenience.
+ If you need to process multiple results, [method search_all] generates a list of all non-overlapping results. This can be combined with a [code]for[/code] loop for convenience.
[codeblock]
for result in regex.search_all("d01, d03, d0c, x3f and x42"):
print(result.get_string("digit"))
@@ -43,7 +43,7 @@
<return type="void">
</return>
<description>
- This method resets the state of the object, as it was freshly created. Namely, it unassigns the regular expression of this object.
+ This method resets the state of the object, as if it was freshly created. Namely, it unassigns the regular expression of this object.
</description>
</method>
<method name="compile">
@@ -52,7 +52,7 @@
<argument index="0" name="pattern" type="String">
</argument>
<description>
- Compiles and assign the search pattern to use. Returns OK if the compilation is successful. If an error is encountered the details are printed to STDOUT and FAILED is returned.
+ 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="get_group_count" qualifiers="const">
@@ -93,7 +93,7 @@
<argument index="2" name="end" type="int" default="-1">
</argument>
<description>
- Searches the text for the compiled pattern. Returns a [RegExMatch] container of the first matching result if found, otherwise null. 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 without modifying where the start and end anchor would be.
</description>
</method>
<method name="search_all" qualifiers="const">
@@ -106,7 +106,7 @@
<argument index="2" name="end" type="int" default="-1">
</argument>
<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 without modifying where the start and end anchor would be.
</description>
</method>
<method name="sub" qualifiers="const">
@@ -123,7 +123,7 @@
<argument index="4" name="end" type="int" default="-1">
</argument>
<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 without modifying where the start and end anchor would be.
</description>
</method>
</methods>
diff --git a/modules/regex/doc_classes/RegExMatch.xml b/modules/regex/doc_classes/RegExMatch.xml
index 245201006d..398d2ee3b6 100644
--- a/modules/regex/doc_classes/RegExMatch.xml
+++ b/modules/regex/doc_classes/RegExMatch.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RegExMatch" inherits="Reference" category="Core" version="3.2">
<brief_description>
- Contains the results of a regex search.
+ Contains the results of a [RegEx] search.
</brief_description>
<description>
- Contains the results of a single regex match returned by [method RegEx.search] and [method 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 sub-string for you.
+ Contains the results of a single [RegEx] match returned by [method RegEx.search] and [method 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.
</description>
<tutorials>
</tutorials>