New course! Every coder should learn Generative AI!
Try a free lesson0
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 ?
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
0
emails="[email protected]@[email protected]"
import re
print(re.findall(r"\w+@[a-z]+(?:\.[a-z]{2,4})+", emails))
0
Thank u all guys. You are awesome.
- 1
hi