Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    extract email address

    General Discussion
    3
    7
    2538
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Ralph Ratz
      Ralph Ratz last edited by

      Hi all,

      I have a huge list of email addresses in this format:

      name1, surname1 surname1.name1@email.com; name2, surname2 surname2.name2@email.com; …

      And I want just have the emails listed in one row like this:

      surname1.name1@email.com
      surname2.name2@email.com
      .
      .
      .
      How can I do this?

      Regards, Ralph

      Scott Sumner 1 Reply Last reply Reply Quote 2
      • Scott Sumner
        Scott Sumner @Ralph Ratz last edited by

        @Ralph-Ratz

        Assuming very well-formed data like you show, I’d start by trying:

        Find what zone: (?-s).+?, .+? (.+?); <-----note the trailing space
        Replace with zone: \1\r\n <------- assumes you want Windows line-endings
        Search mode: Regular expression

        1 Reply Last reply Reply Quote 1
        • Ralph Ratz
          Ralph Ratz last edited by

          it seems the list was not displayed correctly…
          The arrow brackets were not shown. Here it is how it looks like (I had to add an space after the @ symbol to get it displayed)

          name1, surname1 <surname1.name1@ email.com>; name2, surname2 <surname2.name2@ email.com>; …

          1 Reply Last reply Reply Quote 1
          • PeterJones
            PeterJones last edited by

            For future refernce, if you indent the line by 4 spaces in your post (with blank lines before and after), it will show up unformatted here, so the forum won’t mess with it. Or you could put it between back ticks, like `my <data@here>`, which will render as my <data@here>.

            So, do you have anything else in this file that needs to stay, or do you really just want everything that is within angle brackets to be put one per line? For that, I’d use something like:

            • find: (?-s).*?<([^>]*)>
            • replace: $1\r\n
            • regular expression
            1 Reply Last reply Reply Quote 0
            • Scott Sumner
              Scott Sumner last edited by Scott Sumner

              Nobody looks at the PREVIEW pane before hitting Submit to make sure their data is correct. Sigh.

              :-(

              BTW, changing the data so it displays “correctly” changes the problem!

              1 Reply Last reply Reply Quote 2
              • Ralph Ratz
                Ralph Ratz last edited by

                this worked perfect!

                Thank you…
                :-)

                1 Reply Last reply Reply Quote 1
                • PeterJones
                  PeterJones last edited by

                  @Ralph-Ratz ,

                  I’m glad it’s working for you.

                  If you are going to be doing more regular expression manipulation of your text files (including if you ever just want to tweak this regex in order to make some change, like only doing ones that have semicolon’s after the > or something), you are going to want to study regex yourself.

                  We have a FAQ entry which explains where to find regex docs, which is a good starting point for learning about them. I’d recommend searching through some of those, and seeing if you can understand everything in the regex I gave. After reading the docs, if you’re having trouble understanding a portion of it, feel free to ask, and we can help clarify.

                  If you come back for future requests for regex help: please craft your own expression… and if it doesn’t work, then you can ask us, including: show what you tried, explain why you tried that (ie, what you think the regex should do, and what you think each piece of the regex is doing), and show what results you get that doesn’t match your expectations. This will help us to help you better.

                  (And the post “How to Markdown code on this Forum” will help you format posts, so the data exactly represents your actual data.)

                  1 Reply Last reply Reply Quote 1
                  • First post
                    Last post
                  Copyright © 2014 NodeBB Forums | Contributors