๐ Regex & Text Processing
re.search & re.match
Find a pattern anywhere in a string.
Use re.search to find the first match anywhere, re.match to anchor at the start.
import re
m = re.search(r"\d+", "order 1234 shipped")
print(m.group()) # 1234
Common metacharacters: \d digit, \w word char, \s whitespace, + one-or-more, * zero-or-more, ? optional.