Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我觉得通过将这两个正则表达式视为一个,我可以学到很多东西。主要是选择和之间的空格,>而<不是选择>和<本身,所以我可以用“”而不是“><”来替换它。有没有办法在不选择那个空间的情况下合并这些?
>
<
$html = preg_replace('/(\n)|(\r)/',"",$html); $html = preg_replace('/>(\s+)</',"><",$html);
$html = preg_replace('/[\n\r]+|(?<=>)\s+(?=<)/',"",$html);