Added a live-edit RegEx tester to the demos
This commit is contained in:
parent
d9f1a85948
commit
4ca0399ff6
3 changed files with 26 additions and 0 deletions
4
demos/misc/regex/engine.cfg
Normal file
4
demos/misc/regex/engine.cfg
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
[application]
|
||||||
|
|
||||||
|
name="RegEx"
|
||||||
|
main_scene="res://regex.scn"
|
22
demos/misc/regex/regex.gd
Normal file
22
demos/misc/regex/regex.gd
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
extends VBoxContainer
|
||||||
|
|
||||||
|
var regex = RegEx.new()
|
||||||
|
|
||||||
|
func update_expression():
|
||||||
|
regex.compile(get_node("Expression").get_text())
|
||||||
|
update_text()
|
||||||
|
|
||||||
|
func update_text():
|
||||||
|
var text = get_node("Text").get_text()
|
||||||
|
regex.match(text)
|
||||||
|
var list = get_node("List")
|
||||||
|
for child in list.get_children():
|
||||||
|
child.queue_free()
|
||||||
|
for res in regex.get_capture_list():
|
||||||
|
var label = Label.new()
|
||||||
|
label.set_text(res)
|
||||||
|
list.add_child(label)
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
get_node("Text").set_text("They asked me \"What's going on \\\"in the manor\\\"?\"")
|
||||||
|
update_expression()
|
BIN
demos/misc/regex/regex.scn
Normal file
BIN
demos/misc/regex/regex.scn
Normal file
Binary file not shown.
Loading…
Reference in a new issue