$string = 'python perl pear php'; // 获取p后面不是h的单词 $preg = '/p(?!h)[a-z]+/'; $status = preg_match_all($preg, $string, $matches); var_dump($matches);