forked from x4nth055/pythoncode-tutorials
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsub.py
More file actions
Latest commit
16 lines (15 loc) · 486 Bytes
/
Copy pathsub.py
File metadata and controls
16 lines (15 loc) · 486 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
importre
# a basic regular expression for email matching
email_regex=r"[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+"
# example text to test with
example_text="""
Subject: This is a text email!
From: John Doe <john@doe.com>
Some text here!
===============================
Subject: This is another email!
From: Abdou Rockikz <example@domain.com>
Some other text!
"""
# substitute any email found with [email protected]
print(re.sub(email_regex, "[email protected]", example_text))