Skip to content

Commit 09d4b54

Browse files
committed
Add email regex example
1 parent c03431b commit 09d4b54

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

chapter_1/regex/email.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import re
2+
3+
email = re.compile(r'(?P<user>[\w.]+)@(?P<domain>\w+)\.(?P<suffix>[a-z]{3})')
4+
text = "My email is [email protected] or [email protected]"
5+
print(*(x.groupdict() for x in email.finditer(text)))

0 commit comments

Comments
 (0)