Skip to content

Commit 5b78f5c

Browse files
committedFeb 27, 2020
Improve the RegEx class documentation
This closes godotengine/godot-docs#2522.
1 parent e66d519 commit 5b78f5c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎modules/regex/doc_classes/RegEx.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
var regex = RegEx.new()
1111
regex.compile("\\w-(\\d+)")
1212
[/codeblock]
13-
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].
13+
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].
1414
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].
1515
[codeblock]
1616
var regex = RegEx.new()
@@ -35,6 +35,8 @@
3535
# Would print 01 03 3f 42
3636
# Note that d0c would not match
3737
[/codeblock]
38+
[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].
39+
[b]Tip:[/b] You can use [url=https://regexr.com/]Regexr[/url] to test regular expressions online.
3840
</description>
3941
<tutorials>
4042
</tutorials>

0 commit comments

Comments
 (0)
Please sign in to comment.