regex.gd 532 B

12345678910111213141516171819202122232425
  1. extends VBoxContainer
  2. var regex = RegEx.new()
  3. func _ready():
  4. $Text.set_text("They asked me \"What's going on \\\"in the manor\\\"?\"")
  5. update_expression($Expression.text)
  6. func update_expression(text):
  7. regex.compile(text)
  8. update_text()
  9. func update_text():
  10. for child in $List.get_children():
  11. child.queue_free()
  12. if regex.is_valid():
  13. var matches = regex.search($Text.get_text())
  14. if matches != null:
  15. for result in matches.get_strings():
  16. var label = Label.new()
  17. label.text = result
  18. $List.add_child(label)