0
Whats the problem with this code
import re pattern = r"([\w\.-]+)@([\w\.-]+)(\.[\w\.]+)" str = "Please contact the following email for assistance info@sololearn.com, okekeifeomachristiana@gmail.com, okekeraphaelblaze@gmail.com" match = re.findall(pattern, str) if match: print(match.groups())
2 Réponses
+ 2
Replace:
print(match.groups())
With:
print(match)
0
The "match" in your code is a list of matches, not a match object, so it doesn't have the groups() method.
If you want to extract the email addresses, you'll have to modify the code a bit more. Here are two ways to do it:
https://code.sololearn.com/cu18lenBYnoZ/?ref=app
https://code.sololearn.com/cK2l8ddttMIr/?ref=app