From 4ca0399ff6a16c7e5e760d57a7675df61f1f8ef0 Mon Sep 17 00:00:00 2001 From: Zher Huei Lee Date: Fri, 24 Jul 2015 13:55:18 +0100 Subject: Added a live-edit RegEx tester to the demos --- demos/misc/regex/engine.cfg | 4 ++++ demos/misc/regex/regex.gd | 22 ++++++++++++++++++++++ demos/misc/regex/regex.scn | Bin 0 -> 1770 bytes 3 files changed, 26 insertions(+) create mode 100644 demos/misc/regex/engine.cfg create mode 100644 demos/misc/regex/regex.gd create mode 100644 demos/misc/regex/regex.scn (limited to 'demos') diff --git a/demos/misc/regex/engine.cfg b/demos/misc/regex/engine.cfg new file mode 100644 index 0000000000..0a6f4f869c --- /dev/null +++ b/demos/misc/regex/engine.cfg @@ -0,0 +1,4 @@ +[application] + +name="RegEx" +main_scene="res://regex.scn" 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() diff --git a/demos/misc/regex/regex.scn b/demos/misc/regex/regex.scn new file mode 100644 index 0000000000..591b60974a Binary files /dev/null and b/demos/misc/regex/regex.scn differ -- cgit v1.2.3 From 87c1e16834a21ac1e42321811cb0efcda4b91b9a Mon Sep 17 00:00:00 2001 From: Zher Huei Lee Date: Fri, 24 Jul 2015 14:09:39 +0100 Subject: Made RegEx API similar to old version --- demos/misc/regex/regex.gd | 4 ++-- demos/misc/regex/regex.scn | Bin 1770 -> 1772 bytes 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'demos') diff --git a/demos/misc/regex/regex.gd b/demos/misc/regex/regex.gd index a2dc62bf83..e648c18093 100644 --- a/demos/misc/regex/regex.gd +++ b/demos/misc/regex/regex.gd @@ -8,11 +8,11 @@ func update_expression(): func update_text(): var text = get_node("Text").get_text() - regex.match(text) + regex.find(text) var list = get_node("List") for child in list.get_children(): child.queue_free() - for res in regex.get_capture_list(): + for res in regex.get_captures(): var label = Label.new() label.set_text(res) list.add_child(label) diff --git a/demos/misc/regex/regex.scn b/demos/misc/regex/regex.scn index 591b60974a..2b62d6b82a 100644 Binary files a/demos/misc/regex/regex.scn and b/demos/misc/regex/regex.scn differ -- cgit v1.2.3