From a249667e3000af6c33e7697ac74c0cd76578450f Mon Sep 17 00:00:00 2001 From: Daniel Heras Quesada Date: Mon, 24 Aug 2026 17:18:34 +0200 Subject: [PATCH] feat: minor regex and casting tests --- src/modules/primitives/casting.py | 6 ++++++ src/modules/primitives/regex.py | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/modules/primitives/casting.py diff --git a/src/modules/primitives/casting.py b/src/modules/primitives/casting.py new file mode 100644 index 0000000..aced3e0 --- /dev/null +++ b/src/modules/primitives/casting.py @@ -0,0 +1,6 @@ +def run(): + print("== Type casting ==") + + value = "1234" + value_int = int(value) + print(f"{type(value)} value: {value + str(5)} and {type(value_int)} value: {value_int + 5}") diff --git a/src/modules/primitives/regex.py b/src/modules/primitives/regex.py index 6dbec99..791ac47 100644 --- a/src/modules/primitives/regex.py +++ b/src/modules/primitives/regex.py @@ -3,3 +3,14 @@ import re def run(): print("== Regular expressions ==") + + test_txt = "This is a long test with more test 1234" + + matched = re.search("test", test_txt) + print(f"Found span: {matched.span()}, as a group: {matched.group()}") + + matched_all = re.findall("^test$", test_txt) + print(f"Found all: {matched_all}") + + replaced = re.sub("[(is)*|(it)*]+", "x", test_txt, 7) + print(f"Repalced at: {test_txt} as: {replaced}")