I have string like this:
Alex Jatt, ([email protected])
amd I'm trying to extract only email address using regex like so:
p = re.search('\((.*?)\)', c)
but print p command prints ([email protected])
How can I modify this regex to get rid of parenthesis?
re.search allows you to pull matched groups out of the regular expression match. In your case, you would want to use p.group(1) to extract the first parenthesized match, which should be the email in the regular expression you have.
without regex solution:
>>> strs="Alex Jatt, ([email protected])"
>>> strs.split(',')[1].strip().strip("()")
'[email protected]'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With