Delete certain amount of characters of e-mail address
o-Samusa-o last edited by
I have list of e-mail addresses and would like to delete to delete a certain amount characters within each e-mail address. I would like come from this:
to something like this:
I would like to keep the first 2 characters before the “.” as well as between the “.” and"@". Can someone help with the right replacement expression?
I am using the expression
to find e-mail addresses.
Terry R last edited by Terry R
Can someone help with the right replacement expression?
I looked up wikipedia for valid email address characters. That site also produced some valid addresses
The list of valid characters was a lot longer than the one you provided, however I went with your list. You may want to visit the website and possibly amend your valid character list if you think it is prudent to do so. That will only be evident from the list you are working on. Bear in mind some of the characters are
metacharactersand will need escaping by using the
\before the character.
So the Replace function is
The search mode MUST be “regular expression” and please have “wrap around” ticked.
I used the below list (which came from the above site as valid addresses) with the regex above
email@example.com firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com firstname.lastname@example.org " "@example.org (space between the quotes) "john..doe"@example.org (quoted double dot) email@example.com (bangified host route used for uucp mailers) firstname.lastname@example.org
and got this resulting list:
email@example.com firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com firstname.lastname@example.org " "@example.org (space between the quotes) "jo..do"@example.org (quoted double dot) email@example.com (bangified host route used for uucp mailers) firstname.lastname@example.org
Note at least 1 of the addresses was incorrectly changed. I mentioned the valid list of characters which include
!so that’s why the one with this character was incorrectly changed. You mileage may vary depending on what list you use as valid characters.
I also need to qualify this solution, it
ONLYworks with 1 address on each line. Otherwise it will edit the domain portion of all email addresses but the last on a single line.
Terry R last edited by
Bear in mind some of the characters are metacharacters and will need escaping by using the \ before the character.
For more info on which characters need
escapingwithin a character class (denoted by the
specifically the paragraph titled
“Metacharacters Inside Character Classes”