Zest.

Python: Regular expressions

A short, tested Python example for regular expressions. Copy it and adjust the names and paths for your project.

Python
import re

m = re.search(r"(\d+)-(\d+)", "tel 555-1234")
if m:
    print(m.group(1), m.group(2))

re.findall(r"\b\w+@\w+\.\w+\b", text)
re.sub(r"\s+", " ", text)

Find it in Zest

Search for “python regular expressions” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More Python examples

All Python examples