0

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,920
  • 1
  • 16
  • 34
  • 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 tet which are in the above format then you could use the below regex and then replace the matched chars with empty string.

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

DEMO

Avinash Raj
  • 166,785
  • 24
  • 204
  • 249
  • 1
    Thank you very much. This solution saved my day. :) What I dont understand is why someone gives me a downvote :( – WeezHard Dec 05 '14 at 12:51
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,708
  • 13
  • 52
  • 80
  • 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