fork download
  1. <?php
  2.  
  3. $contents = file_get_contents("php://stdin");
  4.  
  5. preg_match_all("/[^[:space:]<@]+(?:@[^[:space:]>]+)+/", $contents, $matches);
  6. print_r($matches);
  7. preg_match_all("/\b([a-z0-9%\._\+\-]+@[a-z0-9-\.]+\.[a-z]{2,6})\b/Ui", $contents, $matches);
  8. print_r($matches);
Success #stdin #stdout 0.03s 13112KB
stdin
"Will Alex" <alex13@cit.msu.edu>;"Moita Zact" <zact3@cit.msu.edu>;"Bob Arms" <arms1@cit.msu.edu>;"Meia Terms" <termsma@cit.msu.edu>;

 "Soap, Joe" <joe.soap@example.com>
 Joe Soap  <joe.soap@example.com>
 (Joe Soap) joe.soap@example.com

and turn them into a list where all the above examples are converted to:

 Joe Soap  <joe.soap@example.com>

but it won't handle things like:

 "joe@soap"@example.com
stdout
Array
(
    [0] => Array
        (
            [0] => alex13@cit.msu.edu
            [1] => zact3@cit.msu.edu
            [2] => arms1@cit.msu.edu
            [3] => termsma@cit.msu.edu
            [4] => joe.soap@example.com
            [5] => joe.soap@example.com
            [6] => joe.soap@example.com
            [7] => joe.soap@example.com
            [8] => "joe@soap"@example.com
        )

)
Array
(
    [0] => Array
        (
            [0] => alex13@cit.msu
            [1] => zact3@cit.msu
            [2] => arms1@cit.msu
            [3] => termsma@cit.msu
            [4] => joe.soap@example.com
            [5] => joe.soap@example.com
            [6] => joe.soap@example.com
            [7] => joe.soap@example.com
        )

    [1] => Array
        (
            [0] => alex13@cit.msu
            [1] => zact3@cit.msu
            [2] => arms1@cit.msu
            [3] => termsma@cit.msu
            [4] => joe.soap@example.com
            [5] => joe.soap@example.com
            [6] => joe.soap@example.com
            [7] => joe.soap@example.com
        )

)