Having a file, for example an extraction from your mailbox, and you want to extract only the email addresses ?
Using Notepad++ and simple regular expression, that’s pretty simple.
See below a full example, or, to summarize, open your file, use below regexp to find email addresses, add line breaks before and after each of them, and then mark the lines containing an email address and delete the unmarked lines.
Starting with your file – in that example, an extraction of the “TO” addresses of an Outlook 2013sent emails folder – you might have a lot of strange characters, unnecessary text, email addresses on the same line, …
File containing email addresses and other information
First step is to open the Replaceoption, Search=> Replaceor Ctrl+H
Search => Replace menu
Here, in Find what, enter below regular expression. (\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b)
In Replace with, enter this to replace each email address by : line break \n + search string $1 + line break \n \n$1\n
Make sure to check the Regular Expressionradio button, and click Replace All
Replace email addresses to add line break before and after each of them
See the result – each email address is now alone on a new line.
File with email addresses separated from the text by line breaks
Next step is to identify all these lines containing only a single email address. Open the Mark tab in the Searchwindow. Copy the same regexp as before to identify the email addresses. Make sure the Regular expressionis checked, along with the Bookmark lineoption, and start the marking operation with Mark All
Options to mark lines containing only an email address
In the file, all lines containing email addresses are now bookmarked.
Email addresses bookmarked in the file
In Search=> Bookmark, select the Remove Unbookmarked Lines
Option to delete unbookmarked lines
And voilà ! Your file now only contains the email addresses without unnecessary text.
Final file containing only email addresses
As a last step, you might want to remove duplicates to have a list of unique email addresses.
Thank you, author, was very useful for me