How can one separate a string of emails with no separator and different domains/number of letters after ‘@‘?
[email protected]@[email protected]@us.org
Is it possible to structure: If ends with .br or .se: separate there Else, separate after .com ?
CodePudding user response:
One possibility is to use regular expression (regex101):
import re
s = "[email protected]@[email protected]@us.org"
emails = re.findall(r"[^@] @[^@] (?:\.com|\.se|\.br|\.org)", s)
print(emails)
Prints:
['[email protected]', '[email protected]', '[email protected]', '[email protected]']