forked from JayRizzo/Random_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
regex_match.py
19 lines (18 loc) · 863 Bytes
/
regex_match.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python3
# =============================================================================
# Created On : MAC OSX High Sierra 10.13.6 (17G65)
# Created On : Python 3.7.0
# Created By : Jeromie Kirchoff
# Created Date: Mon August 15 22:00:03 PDT 2018
# =============================================================================
"""THE MODULE HAS BEEN BUILD FOR."""
# =============================================================================
# IMPORTS
# =============================================================================
import re
str = 'purple [email protected] monkey spacewasher'
match = re.search(r'([\w.-]+)@([\w.-]+)', str)
if match:
print(match.group()) # '[email protected]' (the whole match)
print(match.group(1)) # 'asdf-b' (the username, group 1)
print(match.group(2)) # 'google.com' (the host, group 2)