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}")