1

I am trying to identify and extract emails from sentences. sample example sentences with emails.

sen1 = "Please send an email to joe@gmail.com"
sen2 = "reply to us on raady_07@hotmail.co.kr"
sen3 = "mailing address: raady.07@yahoo.co.se"

I tried using information from this link and this link, and found one expression working for sen1 and sen2

re.findall('\w+?@\w+?\x2E.+', sen1)

I have no problem in identifying for sen1 and sen2. but for sen3 the email has '.' between, so i tried with many trails

re.findall('\w+?\x2E.+@\w+?\x2E.+', sen3)
re.findall('([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*|"([]!#-[^-~ \t]|(\\[\t -~]))+")@[0-9A-Za-z]([0-9A-Za-z-]{0,61}[0-9A-Za-z])?(\.[0-9A-Za-z]([0-9A-Za-z-]{0,61}[0-9A-Za-z])?)+', sen3)
re.findall( ,sen3)

I could not even understand what the complicated expression is doing, it returns an empty list ([]) even for sen1 and sen2. how to identify such emails as in sen3?

Raady
  • 1,686
  • 5
  • 22
  • 46

1 Answers1

1

You could try

\S+@\S+

and verify later if the address actually exists, see a demo on regex101.com.

Jan
  • 42,290
  • 8
  • 54
  • 79