I have this string emails="red23@gmail.com23sed27@hotmail.com78drt88@outlook.es" how can I extract only the emails with regex | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I have this string emails="[email protected]@[email protected]" how can I extract only the emails with regex

Hola can I solve this using regular expressions ?

27th Jun 2020, 2:39 AM
Rodrigo Cerna Bello
Rodrigo Cerna Bello - avatar
4 Answers
+ 3
try the regex to find the mail with positive lookahed. (?=@) it;ll look for @ after the match. ex. ^([0-9]+)(?=a) will match 96698569abcf 68536afhom but not 686bcs
27th Jun 2020, 4:20 AM
Taste
Taste - avatar
0
emails="[email protected]@[email protected]" import re print(re.findall(r"\w+@[a-z]+(?:\.[a-z]{2,4})+", emails))
27th Jun 2020, 12:43 PM
Russ
Russ - avatar
0
Thank u all guys. You are awesome.
27th Jun 2020, 10:34 PM
Rodrigo Cerna Bello
Rodrigo Cerna Bello - avatar
- 1
hi
20th Apr 2021, 2:57 AM
Drze Gdeeh
Drze Gdeeh - avatar