$re = '/(?:\G|^)(?=.*。)(?!.*,)(.*?)。/m';
$str = '<h1>这是一个测试。<h1>
这是一个测试,这是一个测试而已,希望去掉不需要的。
测试。测试。测试。
这是一个测试,这是一个测试而已,希望去掉不需要的第二行。';
$subst = "$1";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php