How To Extract Email Addresses From Text?

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 discussion on “Extract email from text using notepad++ and regexp”, and with further inspiration from a discussion “How to delete all lines in Notepad++ except lines containing a word I need?”.

(\b[A-Za-z0-9._%+-][email protected][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._%+-][email protected][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


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

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.

How to extract email addresses from text file?

address,  ⏧ bookmark,  ⏧ delete,  ⏧ email,  ⏧ extract,  ⏧ extract email adress,  ⏧ extract email adresses from file,  ⏧ extract emails,  ⏧ file,  ⏧ find

Comments (7)

 2018-08-19 -  Irene Page
Simple, clair et bien expliqué, merci beaucoup
 2018-08-19 -  Lee Ryan
No sabía acerca de estos detalles, por favor haga más
 2018-08-19 -  Raymond Mcbride
O poveste grozavă, mulțumesc pentru schimbul
 2018-08-19 -  Kathryn Baker
ที่ทำงานได้ดีสำหรับฉันไม่จำเป็นต้องดูเพิ่มเติมใด ๆ
 2018-11-05 -  testkingaws
Thank you, author, was very useful for me
 2019-01-15 -  George Mauricio Santana Lima
 2019-01-15 -  Kaspars
Thank you! This came handy!

Leave a comment