How Do You Return A List Of The Matched Item In String With Regex?
I made this simple functions that searches for emails in the source code of a page , the content is just the response taken from get request , now how do you return the matchs in f
Solution 1:
import re
your regex is wrong , . matches all occurance
def find_emails(content):
email_reg = r"^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$"
mail_lst = re.findall(email_reg , content)
return mail_lst
print(find_emails("hiiii@asdasd.££$%%$com"))
print(find_emails("hiiii@asdasd.asdasd.com"))
Post a Comment for "How Do You Return A List Of The Matched Item In String With Regex?"