summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2020-02-27 23:09:32 +0100
committerHugo Locurcio <hugo.locurcio@hugo.pro>2020-02-27 23:09:32 +0100
commit5b78f5c46458a93a5c0b2fc539fa79845d7d8762 (patch)
treea3ae01ffce8f7b555b38297201dfe91bd6b8b1f9 /modules
parente66d519286693a03bf59eaba0a5f29c1c9b15d64 (diff)
Improve the RegEx class documentation
This closes https://github.com/godotengine/godot-docs/issues/2522.
Diffstat (limited to 'modules')
-rw-r--r--modules/regex/doc_classes/RegEx.xml4
1 files changed, 3 insertions, 1 deletions
diff --git a/modules/regex/doc_classes/RegEx.xml b/modules/regex/doc_classes/RegEx.xml
index e9f46b9853..3130c53331 100644
--- a/modules/regex/doc_classes/RegEx.xml
+++ b/modules/regex/doc_classes/RegEx.xml
@@ -10,7 +10,7 @@
var regex = RegEx.new()
regex.compile("\\w-(\\d+)")
[/codeblock]
- The search pattern must be escaped first for gdscript before it is escaped for the expression. For example, [code]compile("\\d+")[/code] would be read by RegEx as [code]\d+[/code]. Similarly, [code]compile("\"(?:\\\\.|[^\"])*\"")[/code] would be read as [code]"(?:\\.|[^"])*"[/code].
+ The search pattern must be escaped first for GDScript before it is escaped for the expression. For example, [code]compile("\\d+")[/code] would be read by RegEx as [code]\d+[/code]. Similarly, [code]compile("\"(?:\\\\.|[^\"])*\"")[/code] would be read as [code]"(?:\\.|[^"])*"[/code].
Using [method search] you can find the pattern within the given text. If a pattern is found, [RegExMatch] is returned and you can retrieve details of the results using functions such as [method RegExMatch.get_string] and [method RegExMatch.get_start].
[codeblock]
var regex = RegEx.new()
@@ -35,6 +35,8 @@
# Would print 01 03 3f 42
# Note that d0c would not match
[/codeblock]
+ [b]Note:[/b] Godot's regex implementation is based on the [url=https://www.pcre.org/]PCRE2[/url] library. You can view the full pattern reference [url=https://www.pcre.org/current/doc/html/pcre2pattern.html]here[/url].
+ [b]Tip:[/b] You can use [url=https://regexr.com/]Regexr[/url] to test regular expressions online.
</description>
<tutorials>
</tutorials>