re

Stdlib — TextPython 2.0+Intermediate

Regular expression matching, searching, and substitution

Quick Info

Documentation
Official Docs
Python Version
2.0+
Dependencies
None — Python Standard Library
Install
Included with Python

Learn by Difficulty

Quick Example

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.

Try in Playground

Tags

stdlibtext-processingregexpattern-matching

Related Items