๐ Regex & Text Processing
findall & sub
Extract every match or rewrite the string.
re.findall returns every non-overlapping match. re.sub replaces matches with a string or a function's result.
import re
print(re.findall(r"\d+", "a1 b22 c333")) # ['1', '22', '333']
print(re.sub(r"\s+", "_", "hello world py")) # hello_world_py