<?php $subject = "my email is spark@imooc.com"; $pattern='/\s(\w+)@(\w+)\.(com|cn)/'; preg_match($pattern,$subject,$matches); print_r($matches[0]); //在这里补充代码,实现正则匹配,并输出邮箱地址 $subject = "my email is spark@imooc.com";
这是对的,匹配出的就是邮箱地址!