Home > Enterprise >  Remove dots before @ sign in email address
Remove dots before @ sign in email address

Time:02-16

I have this string:

[email protected]

How could I have the dots before the @ sign removed?

The expected output would look like this:

[email protected]

CodePudding user response:

You can use split and replace like so:

string = `[email protected]`
stringList = string.split()
stringList[0] = stringList[0].replace(".","")
new = "@".join(stringList)

Output:

[email protected]

CodePudding user response:

s='[email protected]'
at=s.index('@')
output=s[:at].replace('.','') s[at:]
print(output)

CodePudding user response:

You can just use replace. Set the characters you want to replace and what you want to replace them with, as such:

    string = "[email protected]"
    new = string.replace(".", "")
    print(new)

Prints:

noreplyrandom@gmailcom
  • Related