diff options
author | Zher Huei Lee <lee.zh.92@gmail.com> | 2015-07-24 13:55:18 +0100 |
---|---|---|
committer | Zher Huei Lee <lee.zh.92@gmail.com> | 2015-07-24 13:55:18 +0100 |
commit | 4ca0399ff6a16c7e5e760d57a7675df61f1f8ef0 (patch) | |
tree | ead6bfd3eec1e199981584579cd41d9dab8f7cfc /demos/misc/regex/regex.gd | |
parent | d9f1a85948478fe5038ecc2fd1923c451cca84d5 (diff) |
Added a live-edit RegEx tester to the demos
Diffstat (limited to 'demos/misc/regex/regex.gd')
-rw-r--r-- | demos/misc/regex/regex.gd | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/demos/misc/regex/regex.gd b/demos/misc/regex/regex.gd new file mode 100644 index 0000000000..a2dc62bf83 --- /dev/null +++ b/demos/misc/regex/regex.gd @@ -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() |