How To Extract Email Addresses From Text?

Having a file, for example an extraction from your mailbox, and you want to extract only the email addresses ?


How to extract email addresses from text file?

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.

Notepad++ regex extract text

Pretty straightforward – but see below a full example using this clever regexp from a Stackoverflow.com discussion on “Extract email from text using notepad++ and regexp”.

And also with further inspiration from a superuser.com discussion “How to delete all lines in Notepad++ except lines containing a word I need?”.

(\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b)

Starting with your file – in that example, an extraction of the “TO” addresses of an Outlook 2013 sent emails folder – you might have a lot of strange characters, unnecessary text, email addresses on the same line, …

First step is to open the Replace option, Search => Replace or Ctrl+H .

Nnotepad++ regular expression

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 Expression radio button, and click Replace All.

See the result – each email address is now alone on a new line.

Next step is to identify all these lines containing only a single email address. Open the Marktab in the Search window. Copy the same regexp as before to identify the email addresses. Make sure the Regular expression is checked, along with the Bookmark line option, and start the marking operation with Mark All

In the file, all lines containing email addresses are now bookmarked.

In Search => Bookmark, select the Remove Unbookmarked Lines

And voilà ! Your file now only contains the email addresses without unnecessary text.

As a last step, you might want to  remove duplicates   to have a list of unique email addresses.

Extract emails from text file

To extract emails from a text file, open it using Notepad++ text editor, and apply the instructions above, by using a regular expression, tagging all emails, selecting only the emails, and copying them.

Notepad++ copy all regex matches

To copy all regex matches, use the Marktab in Notepad++ search window. By putting here the regexp, all results matching the regexp will be marked, and can be selected and copied that way.

Notepad++ strip HTML tags

To remove the HTML tags in Notepad++ from a text, use below  regular expression   <.*?>|</.*?>, and replace for example with a space. Make sure that the  regular expression   check box in the search form has been selected.

Notepad++ extract URLs

Become an Excel Pro: Join Our Course!

Elevate your skills from novice to hero with our Excel 365 Basics course, designed to make you proficient in just a few sessions.

Enroll Here

Elevate your skills from novice to hero with our Excel 365 Basics course, designed to make you proficient in just a few sessions.

In the replace menu, accessible with shortcut CTRL+H, use the following regexp, with the  regular expression   and dot matches new line checked:

And use this replace string in order to get a list of all URLs extracted in the file:

How to copy marked lines in NotePad++ ?

Marked text in Notepad++ can be copied using a regex search, by using the search > mark menu, selecting bookmark line and clicking mark all.

Then, use the search > bookmark > copy bookmarked lines menu, and the result can be pasted in a new file, containing the copy of marked lines.

How to extract emails from text in a few clicks?

To extract emails from text, simply enter a  regular expression   to find out all the email addresses in a text file, for example an extraction of all your contacts from Microsoft Outlook.

Then, identify the email addresses, and remove the extra lines. Using NotePad++, it can easily be done by following our guide.

extract email address from Notepad++ using regex

How to extract emails from CSV file?

The email addresses in a CSV, such as a MicrosoftOutlook export, works exactly the same as for a standard text file.

To extract emails from CSV file, start by opening the CSV file with Notepad++ text editor, distinguish the single email addresses with the process explained above, and copy them.

To  extract emails from CSV file   follow the following process:

  • Open the CSV file with Notepad++ text editor,
  • Enter  regular expression   matching potential email addresses,
  • Replace them with email and line break,
  • Use a  regular expression   to bookmark effective email addresses,
  • Remove lines unbookmarked that don’t contain email addresses,
  • Get a final list by performing a  remove duplicates   operation that will clean your file and have the emails extracted from your CSV file and ready to export.

Once the  extract emails from CSV file   process has been completed using a regular expression, you will be able to copy them directly from the results.

GMAIL: How to send an email to all contacts?

Using the popular email application GMAIL, it is possible to send an email to all contacts by first extracting the contact list.

To do so, open your Google contacts, and go to the “other contacts” menu, where you’ll find the email addresses of anyone you’ve ever exchanged an email with.

Then, select a contact by clicking on the checkbox next to it – and a new menu will appear, allowing you to select all contacts you want by expanding the blue arrow, and then to export all your GMAIL contacts emails by clicking on the three blue dots on the right, and selecting the email export options to local file that suits your needs: Google CSV, Outlook CSV, or vCard for iOS contacts.

If you have too many contacts to handle in the resulting CSV file, consider splitting your CSV file.

Split your CSV text file with contacts exported from GMAIL

You can also export all contacts directly from this menu by selecting the appropriate option, the all contacts checkbox.

Frequently Asked Questions

How is the email extractor from text files ?
To extract emails from a text file, open it with the Notepad++ text editor and apply the instructions above using a regular expression, marking all emails, selecting only emails, and copying them.
How to Notepad++ extract email from text?
To remove duplicates in Notepad++, you can use the TextFX plugin. After installing the plugin, select the text you want to sort and navigate to TextFX > TextFX Tools > Sort lines case sensitive (or case insensitive). Make sure 'Sort outputs only UNIQUE (at column) lines' is checked to remove duplicates.
How can I extract email addresses from a text file using Notepad++?
To extract email addresses from a text file in Notepad++, you can use a regular expression search. Open the search dialog with Ctrl + F, switch to the 'Mark' tab, check 'Bookmark line', enter a regular expression to match email addresses (like \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b), and click 'Mark All'. Then, open the 'Search' menu, select 'Bookmark', and 'Copy Bookmarked Lines' to get a list of all email addresses.
What should users do if they encounter an issue loading a 32-bit plugin on Notepad++?
Users should ensure they are running a compatible version of Notepad++ (32-bit version for 32-bit plugins). If issues persist, consider finding an updated version of the plugin or consult the Notepad++ community forums for specific troubleshooting advice.

Yoann Bierling
About the author - Yoann Bierling
Yoann Bierling is a Web Publishing & Digital Consulting professional, making a global impact through expertise and innovation in technologies. Passionate about empowering individuals and organizations to thrive in the digital age, he is driven to deliver exceptional results and drive growth through educational content creation.

Become an Excel Pro: Join Our Course!

Elevate your skills from novice to hero with our Excel 365 Basics course, designed to make you proficient in just a few sessions.

Enroll Here

Elevate your skills from novice to hero with our Excel 365 Basics course, designed to make you proficient in just a few sessions.



Comments (4)

 2018-08-19 -  Irene Page
Simple, clear and well explained, thank you very much
 2018-11-05 -  testkingaws
Thank you, author, was very useful for me
 2019-01-15 -  George Mauricio Santana Lima
THIS TUTORIAL IS AMAZING, SUCH AN USEFUL GUIDE! <3
 2019-01-15 -  Kaspars
Thank you! This came handy!

Leave a comment