<?php
$subject = "my email is spark@imooc.com";
//在这里补充代码,实现正则匹配,并输出邮箱地址
$mail='/my email is:([\w+@\w+\.\w+])/';
preg_match($mail,$subject,$matches);
echo $matches[1];
你的:$mail='/my email is:([\w+@\w+\.\w+])/';其中is后面不应该有:,还有后面是查询子集,把中括号去掉,
换成这样就可以$mail='/my email is (\w+@\w+\.\w+)/';
<?php
$subject = "my email is spark@imooc.com";
//在这里补充代码,实现正则匹配,并输出邮箱地址
$mail='/my email is \w+@\w+\.\w+/';
preg_match($mail,$subject,$matches);
var_dump($matches);