godot/demos/misc/regex/regex.gd

23 lines
532 B
GDScript3
Raw Normal View History

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()
2015-07-24 13:09:39 +00:00
regex.find(text)
var list = get_node("List")
for child in list.get_children():
child.queue_free()
2015-07-24 13:09:39 +00:00
for res in regex.get_captures():
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()