I want to remove everything from the + up to the @, including the +, but not the @
The closest that I have been able to get is using this between regex.
>>> email = "garry+filter@gmail.com"
>>> re.sub(r'\+[^)]*\@', '', email)
garrygmail.com
I want to remove everything from the + up to the @, including the +, but not the @
The closest that I have been able to get is using this between regex.
>>> email = "garry+filter@gmail.com"
>>> re.sub(r'\+[^)]*\@', '', email)
garrygmail.com
Put @ in the replacement string, rather than an empty string.
re.sub(r'\+[^)]*@', '@', email)
BTW, there's no need to escape @.