feat: minor regex and casting tests
This commit is contained in:
6
src/modules/primitives/casting.py
Normal file
6
src/modules/primitives/casting.py
Normal file
@@ -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}")
|
||||
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user