Regex – Notepad++ – Outlook Junk Mail

So I was pretty spam free at work for about 5 years, then I signed up for a VDI seminar. Boom, headshot. I was using Outlook to add all the spam to a Junk mail list but noticed much of it was from the same domain using various subdomains and addresses.  I had hundreds of addresses blocked, but the domains kept using new addresses. Outlook allows you to export your Junk mail list. Outlook allows you to block entire domains using “”. So the challenge was how to take all my entries and change them to How to strip anything before a fixed character? Enter Notepad ++ and regular expressions!

Regular Expressions example – removing text before the @ in email address list

  1. Export Blocked Senders list from Outlook
    • Home > Junk > Junk Email Options > Blocked Senders > Export to file > ihatespam.txt
  2. Open file in Notepad ++
  3. Ctrl + F  for Find
  4. Choose Replace tab
  5. Search Mode = Regular Expressions
  6. Find What =   .*@(.*)
  7. Replace with =   \1
  8. Import the new list into Outlook Blocked Senders
    • Home > Junk > Junk Email Options > Blocked Senders > Import from file  ( ihatespam.txt )
Notepad ++ Regex replace before

List before


List After

Excellent article for many Regular Expression example using Notepad ++

Leave a Reply

Your email address will not be published. Required fields are marked *