How to extract an email-address from a text file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jerry

    How to extract an email-address from a text file

    Hi people:

    Can somebody show me a quick code snippet to reliably extract an
    email-address form a text file ?

    Any help greatly appreciated!
    Jerry
  • James Smith

    #2
    Re: How to extract an email-address from a text file

    Jerry wrote:
    [color=blue]
    >Hi people:
    >
    >Can somebody show me a quick code snippet to reliably extract an
    >email-address form a text file ?
    >
    >Any help greatly appreciated!
    >Jerry
    >
    >[/color]
    Are you a Spammer?

    Comment

    • eclipsboi

      #3
      Re: How to extract an email-address from a text file

      On Mon, 02 Aug 2004 17:20:25 +1000, James Smith
      <jncsmith@optus net.com.au> wrote:
      [color=blue]
      >Jerry wrote:
      >[color=green]
      >>Hi people:
      >>
      >>Can somebody show me a quick code snippet to reliably extract an
      >>email-address form a text file ?
      >>
      >>Any help greatly appreciated!
      >>Jerry
      >>
      >>[/color]
      >Are you a Spammer?[/color]
      If he was, do you think he'd admit to it?

      Comment

      • Ian.H

        #4
        Re: How to extract an email-address from a text file

        On Mon, 02 Aug 2004 18:31:10 +0000, eclipsboi wrote:
        [color=blue]
        > On Mon, 02 Aug 2004 17:20:25 +1000, James Smith
        > <jncsmith@optus net.com.au> wrote:
        >[color=green]
        >>Jerry wrote:
        >>[color=darkred]
        >>>Hi people:
        >>>
        >>>Can somebody show me a quick code snippet to reliably extract an
        >>>email-address form a text file ?
        >>>
        >>>Any help greatly appreciated!
        >>>Jerry
        >>>
        >>>[/color]
        >>Are you a Spammer?[/color]
        > If he was, do you think he'd admit to it?[/color]


        Rule #1: Spammers Lie
        Rule #2: If spammer appears to be telling the trust, see #1
        Rule #3: Spammers are stupid


        Of course he's not a spammer, he's a "direct e-mail marketer"
        hahaha =)



        Regards,

        Ian


        XP: stripped

        --
        Ian.H
        digiServ Network
        London, UK


        Comment

        • Gary L. Burnore

          #5
          Re: How to extract an email-address from a text file

          On Sun, 01 Aug 2004 23:03:30 +0200, Jerry <submitstuff@ly cos.com>
          wrote:
          [color=blue]
          >Hi people:
          >
          >Can somebody show me a quick code snippet to reliably extract an
          >email-address form a text file ?[/color]


          Get a pen and a piece of paper. Read the text file. Read and weite
          down the email address.


          BTW, did you ear a Korean firm just bought Lycos? Hahahahahahaha.
          They've got YOUR number.

          Comment

          • Nikolai Chuvakhin

            #6
            Re: How to extract an email-address from a text file

            Jerry <submitstuff@ly cos.com> wrote in message
            news:<vemqg091o 1raraqn7edv3k0q 1p202cuj1p@4ax. com>...[color=blue]
            >
            > Can somebody show me a quick code snippet to reliably extract an
            > email-address form a text file ?[/color]

            Here's a lazy (as in "too lazy to learn regular expressions") one:

            function get_addresses($ file) {
            $breaking = array(' ', ',', '>', '<', "\t", "\r", "\n");
            $addr = array();
            $data = explode('@', file_get_conten ts($file));
            // Alternative for PHP < 4.3.0:
            // $data = explode('@', implode('', file($file)));
            $n = count($data);
            for ($i = 1; $i < $n; $i++) {
            $addr[$i-1] = '@';
            $begin = 0;
            $end = strlen($data[$i-1]) - 1;
            while ((!in_array($da ta[$i-1]{$end}, $breaking)) and ($begin <= $end)) {
            $addr[$i-1] = $data[$i-1]{$end} . $addr[$i-1];
            $end--;
            }
            $begin = 0;
            $end = strlen($data[$i]) - 1;
            while ((!in_array($da ta[$i]{$begin}, $breaking)) and ($begin <= $end)) {
            $addr[$i-1] .= $data[$i]{$begin} ;
            $begin++;
            }
            }
            if (count($addr) == 0) {
            return FALSE;
            } else {
            return $addr;
            }
            }

            This function returns an array including all e-mail addresses found
            in the $file or FALSE if no address is found.

            Cheers,
            NC

            Comment

            • eclipsboi

              #7
              Re: How to extract an email-address from a text file

              On 3 Aug 2004 15:09:06 -0700, nc@iname.com (Nikolai Chuvakhin) wrote:
              [color=blue]
              >This function returns an array including all e-mail addresses found
              >in the $file or FALSE if no address is found.
              >
              >Cheers,
              >NC[/color]

              You do realize you probably just doubled the junk mail in all of our
              mailboxes now, right? ;)

              Comment

              Working...