GDScript regular expressions made easy.
MIT License
A port of VerbalExpressions to GDScript. Tested on Godot 3.4.x.
Based on the Java implementation.
An itch.io demo can be found here.
See the tests
directory for more examples.
addons/verbal-expressions/
folder to your project's addons
directory (create the addons
directory if it doesn't exist)verbal_expressions.gd
file in your script and create a new instance of itbuild()
to compile the expressionReGex
methods to do regex stuffVerify a URL
var verbal_expressions = load("res://addons/verbal-expressions/verbal_expressions.gd").new()
verbal_expressions \
.start_of_line() \
.then("http") \
.maybe("s") \
.then("://") \
.maybe("www.") \
.anything_but(" ") \
.end_of_line() \
.build()
var regex_match = verbal_expressions.search("https://godotengine.org/")
assert(regex_match != null)
# Technically unnecessary since `search(...)` returns null if there is no match
assert(regex_match.get_string() == "https://godotengine.org/")