$string = 'caoyang@sina.com'; // 匹配@之前的部分 $preg = '/.*(?=@)/'; $status = preg_match_all($preg, $string, $matches); var_dump($matches);