R
R
red-web2016-03-06 03:06:50
Regular Expressions
red-web, 2016-03-06 03:06:50

How to find all emails in the body of an html document using regular expressions?

I don't understand why this code

<?
  $page=file_get_contents("http://www.nash-kabinet.ru/");
  $pattern="/[^@\s][email protected]\S++/";
  preg_match_all($pattern, $page, $result);
  print_r($result);
?>

gives me this result
Array ( [0] => Array ( [0] => '[email protected]'; [1] => e-mail:[email protected]
) )

How to get rid of 'e-mail:', can anyone have the correct spelling?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2016-03-06
@red-web

/\b[\w._%+-][email protected][\w.-]+\.[A-Z]{2,}\b/i
ideone.com/96v4JL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question