find email address pytho 1

find email address pytho

import re
line = "should we use regex more often? let me know at  321dsasdsa@dasdsa.com.lol"
match = re.search(r'[\w\.-]+@[\w\.-]+', line)
match.group(0)
'321dsasdsa@dasdsa.com.lol'

Here is what the above code is Doing:
1. The first part of the regular expression, [\w\.-]+ matches one or more word characters, dots, or hyphens.
2. The second part of the regular expression, @, matches the literal character @.
3. The third part of the regular expression, [\w\.-]+ matches one or more word characters, dots, or hyphens.

Similar Posts