Professional Documents
Culture Documents
Project 7
Project 7
import re
email_regex = r'\b\w+@\w+\.\w{2,}\b'
#r at the beginning of the pattern is used to indicate that this is a raw string in
Python,
#\b matches a word boundary, which is the point where a word character (i.e., a
letter, digit, or underscore) is adjacent to a non-word character
#(i.e., a space, punctuation mark, or the beginning or end of a line).
#\w+ matches one or more word characters, which can include letters, digits, and
underscores.
#@ matches the "@" symbol that separates the username and domain name in an email
address.
#\., which is a backslash followed by a period, matches a literal period character.
#\w{2,} matches two or more word characters in the top-level domain name (e.g.,
com, org, edu).
#\b matches another word boundary, which ensures that the pattern only matches
complete email addresses
#and not partial matches.
# Use the findall() method to extract all email addresses in the text
print(usernames)