re — Easy Examples
Regular expression matching, searching, and substitution
Getting started with re
Basic import and usage of the re module.
python
import re text = "Contact: john@email.com or jane@example.org" emails = re.findall(r'[\w.]+@[\w.]+', text) print(f"Found emails: {emails}") # Replace result = re.sub(r'\d+', 'X', "Order #123, Item #456") print(result)
The re module is part of Python's standard library. Regular expression matching, searching, and substitution.
Common re operations
Frequently used functions from the re module.
python
# More re examples import re print(f"re module loaded successfully") print(f"Location: {re.__name__}") print(f"Has {len(dir(re))} attributes")
These are the most commonly used features of the re module.
Want to try these examples interactively?
Open Easy Playground