Use regex (preg_match_all) to extract e-mail from a page

in

When parsing a site to harvest e-mail , we use Regex with preg_match_all() function to get all e-mail but the problem is that in some html,  user type email like that : abc @ gmail.com
 
How we solve this issue. Use this regex pattern:
 
$pattern="/([\s]*)([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*([ ]+|)@([ ]+|)([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,}))([\s]*)/i"; preg_match_all($pattern, $html_page, $matches);
 
That pattern will extract all type of email.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
15 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.