diff options
Diffstat (limited to 'demos/misc/regex')
-rw-r--r-- | demos/misc/regex/engine.cfg | 5 | ||||
-rw-r--r-- | demos/misc/regex/icon.png | bin | 0 -> 2215 bytes | |||
-rw-r--r-- | demos/misc/regex/regex.gd | 24 | ||||
-rw-r--r-- | demos/misc/regex/regex.scn | bin | 0 -> 1793 bytes |
4 files changed, 29 insertions, 0 deletions
diff --git a/demos/misc/regex/engine.cfg b/demos/misc/regex/engine.cfg new file mode 100644 index 0000000000..ef5483e096 --- /dev/null +++ b/demos/misc/regex/engine.cfg @@ -0,0 +1,5 @@ +[application] + +name="RegEx" +main_scene="res://regex.scn" +icon="res://icon.png" diff --git a/demos/misc/regex/icon.png b/demos/misc/regex/icon.png Binary files differnew file mode 100644 index 0000000000..7a5232ec4b --- /dev/null +++ b/demos/misc/regex/icon.png diff --git a/demos/misc/regex/regex.gd b/demos/misc/regex/regex.gd new file mode 100644 index 0000000000..409b4cab05 --- /dev/null +++ b/demos/misc/regex/regex.gd @@ -0,0 +1,24 @@ +extends VBoxContainer + +var regex = RegEx.new() + +func update_expression(text): + regex.compile(text) + update_text() + +func update_text(): + var text = get_node("Text").get_text() + var list = get_node("List") + for child in list.get_children(): + child.queue_free() + 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(get_node("Expression").get_text()) + diff --git a/demos/misc/regex/regex.scn b/demos/misc/regex/regex.scn Binary files differnew file mode 100644 index 0000000000..1f46521d0d --- /dev/null +++ b/demos/misc/regex/regex.scn |