Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php抓取电子邮件模式_Php_Regex - Fatal编程技术网

Php抓取电子邮件模式

Php抓取电子邮件模式,php,regex,Php,Regex,可能重复: 我想通过下面的纸条获取带有页面的电子邮件,但我不确定preg_match_all中使用的模式 $original_file = file_get_contents("http://www.example.com/"); $stripped_file = strip_tags($original_file, "<a>"); preg_match_all("/<a(?:[^>]*)href=\"([^\"]*)\"(?:[^>]*)>(?:[^

可能重复:

我想通过下面的纸条获取带有页面的电子邮件,但我不确定preg_match_all中使用的模式

 $original_file = file_get_contents("http://www.example.com/");
 $stripped_file = strip_tags($original_file, "<a>");
 preg_match_all("/<a(?:[^>]*)href=\"([^\"]*)\"(?:[^>]*)>(?:[^<]*)<\/a>/is", $stripped_file, $matches);

 header("Content-type: text/plain"); 
 print_r($matches); //View the array to see if it worked
$original\u file=文件获取内容(“http://www.example.com/");
$stripped_file=strip_标签($original_file,“”);

preg\u match\u all(“/]*)href=\”([^\“]*)\”(?:[^>]*)>(?:[^编辑:我刚意识到你的意思是邮件链接

请回答:


使用HTML解析器可能会更幸运,例如,它可以让您以更自然的方式解析HTML文档,例如:

// Find all anchors, returns a array of element objects
$ret = $html->find('a');

然后循环遍历返回元素的数组,并检查
href
中是否有类似@symbol的内容。

strip_tags()的第二个参数设置要保留的标记。