summaryrefslogtreecommitdiff
path: root/demos/misc
diff options
context:
space:
mode:
authorZher Huei Lee <lee.zh.92@gmail.com>2015-10-20 09:51:00 +0100
committerZher Huei Lee <lee.zh.92@gmail.com>2015-11-07 11:03:24 +0000
commitbb3724a4cc737599d5b12abeb8b1590781bb5ddb (patch)
tree0eed8e07f3ab13d2a723a995bc8211fc2b5ca9f2 /demos/misc
parent26b977c96795172b1e095c06222eb30cfc6f4cb7 (diff)
Updated RegEx demos
Diffstat (limited to 'demos/misc')
-rw-r--r--demos/misc/regex/regex.gd18
-rw-r--r--demos/misc/regex/regex.scnbin1772 -> 1793 bytes
2 files changed, 10 insertions, 8 deletions
diff --git a/demos/misc/regex/regex.gd b/demos/misc/regex/regex.gd
index e648c18093..409b4cab05 100644
--- a/demos/misc/regex/regex.gd
+++ b/demos/misc/regex/regex.gd
@@ -2,21 +2,23 @@ extends VBoxContainer
var regex = RegEx.new()
-func update_expression():
- regex.compile(get_node("Expression").get_text())
+func update_expression(text):
+ regex.compile(text)
update_text()
func update_text():
var text = get_node("Text").get_text()
- regex.find(text)
var list = get_node("List")
for child in list.get_children():
child.queue_free()
- for res in regex.get_captures():
- var label = Label.new()
- label.set_text(res)
- list.add_child(label)
+ if regex.is_valid():
+ regex.find(text)
+ 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()
+ update_expression(get_node("Expression").get_text())
+
diff --git a/demos/misc/regex/regex.scn b/demos/misc/regex/regex.scn
index 2b62d6b82a..1f46521d0d 100644
--- a/demos/misc/regex/regex.scn
+++ b/demos/misc/regex/regex.scn
Binary files differ