I have a list of emails, and I want to change the two letters before "@" and the first letter after "@" using Notepad++.

For example:



  • 9
    Just an obvious remark, the concrete example you gave shows how useless this pattern would be to anonymize email addresses. It’s usually better like x******@y***.com – eckes Mar 15 at 11:11
  • @eckes would that even be possible in N++? – WELZ Mar 15 at 17:13
  • 3
    @WELZ Yes but its more work, a half working sample would (.)[^@]*@([^.]).*(\.[a-z]+) use 3 capture groups which you can address in the replace with string: \1***@\2***\3 - uses a fixed number of mask characters but this is actually good. – eckes Mar 15 at 18:17

I want to change the two letters before "@" and the first letter after "@"

  • Menu "Search" > "Replace" (or Ctrl + H)

  • Set "Find what" to ..@.

  • Set "Replace with" to **@*

  • Enable "Regular expression"

  • Click "Replace All"

    enter image description here





Further reading

  • DavidPostill thanks,it worked for me. – loveman2019 Mar 15 at 8:17
  • I'd say it should be .?.@. as there might not be two characters before @. – n0rd Mar 16 at 18:55
  • 1
    @n0rd The question specified two characters, but you are correct if there is only one. – DavidPostill Mar 16 at 19:07

You can do this by using a regex search/replace.

At the bottom, select Regular Expression.

In the Search for entry, you type in: ..@. In the Replace with, you type in **@*

Then press the button Replace All

This works because Regex searches will only replace if its search criteria matches exactly. The match is explained as follows:

..@. There are 3 dots and an @:

  • @ has no special meaning in regex so it means a literal @.
  • . means any character, exactly once. By writing .. it means 2 characters of any kind, as long as there are 2 characters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.