Menu

How can I extract these email addresses?

Mike
2008-08-26
2012-11-13
  • Mike

    Mike - 2008-08-26

    Say I have a bunch of webforms that were submitted and I want to extract the email address of the submitter from them. I've already converted the emails to .mbox files so I can open them with Notepad++

    If the line is the same in every single email, I think there should be a way I can extract all these emails in one swoop? This is the line:

    Click to E-mail: joeblow@whatever.com?Subject=Website_Contact

    Is there a way I can say to take everything after click to email, up to but not including that question mark and then get all those emails into a file?

     
    • Alexander Iljin

      Alexander Iljin - 2008-08-27

      I would use a simple SED script to do the job. SED stands for the "Stream EDitor", a GNU freeware program. Here is the command line (written under Windows):

      sed -n -e "s/Click to E-mail: \([-a-zA-Z0-9_.@]\+\).*/\1/ p" <file.mbox >>emails.txt

      Input file name: file.mbox (substitute other files here, one at a time);
      Output file name: emails.txt (extracted e-mails are appended to this file);
      [a-zA-Z0-9_\-\.@] - regular expression that specifies which characters an e-mail address may contain.
      These include a minus sign, letters "a" to "z" and "A" to "Z", underscore, period and "@". Leading minus is taken literally and is not interpreted as part of a character range specification;
      \(...\) - parenthesis group characters to be extracted (presumably an e-mail address);
      "Click to E-mail: " is the prefix before an e-mail, it must match exactly, character-by-character;
      s/.../.../ is the "substitute" command.

      SED Introduction and Tutorial: http://www.grymoire.com/Unix/Sed.html

       
      • Mike

        Mike - 2008-08-27

        Wow that is way out of my league, but thank you!
        I found a site online that lets you paste a file and then it extracts email addresses, worked pretty well. But next time I'll try your command line program (as long as I know the command line!!!)

         
    • Fool4UAnyway

      Fool4UAnyway - 2008-08-27

      Use TextCrawler to do this.
      It has a built-in regular expression for email addresses.
      Just select it and choose the files to extract from and have TextCrawler do the work for you.

      See the message

      "Tools to find and copy regex matches in files"
      By: Fool4UAnyway (fool4uanyway) - 2008-04-19 23:49
      http://sourceforge.net/forum/message.php?msg_id=4915704

      in the thread

      "copy to clip all text matching regex pattern" (Help forum)
      http://sourceforge.net/forum/forum.php?thread_id=2012623&forum_id=331754

       
      • Mike

        Mike - 2008-08-27

        Thanks! TextCrawler is great!!!!! Do you know of a way for it to remove duplicates when it extracts?