re
1import re
2
3# get first email address
4txt = "hello: support@example.com or sales@foo.cn"
5m = re.search(r"[\w.-]+@[\w.-]+\.\w+", txt)
6print(m.group(0) if m else "not found") # support@example.com
7
8# split string by consecutive whitespace
9pattern = re.compile(r"\s+") # compile
10parts = pattern.split("a\tb c\nd")
11print(parts) # ['a', 'b', 'c', 'd']