1

I have a big file with a large list of emails like:

Some Name <same.name@example.com>
same.name2@example.com
Some Name3 (same.name3@example.com)
Some Name4 (same.name4@example.com)

How can I delete all other text to have only a list like:

same.name@example.com
same.name2@example.com
same.name3@example.com
same.name4@example.com

Thanks

WeezHard
  • 1,982
  • 1
  • 16
  • 37
  • hi @phresnel, Based on this post: http://stackoverflow.com/questions/26274048/extract-email-from-text-usin-notepad-and-regexp I try to use this regular expression: \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b But this select the email. I want to select all other things except the emails. – WeezHard Dec 05 '14 at 12:49

2 Answers2

2

If the file contains the text which are in the above format then you could use the below regex and then replace the matched chars with empty string.

^.*[<(]|[>)].*

DEMO

AndyUK
  • 3,933
  • 7
  • 42
  • 44
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
2

This regex will match the email addresses

[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?

At this point you could cut them out.

Eamonn McEvoy
  • 8,876
  • 14
  • 53
  • 83
  • Not sure `^^^^^^^^^@0------------0.0-------------0` is a valid email address but your regex matches it. – Toto Dec 05 '14 at 12:23
  • 1
    Very helpful, thanks! One addition: If you work with Notepad++ and you want to cut out the found email addresses you can do this by following these steps: http://stackoverflow.com/a/8231096/3194543 – Stefan Seidner-Britting Oct 09 '16 at 20:58