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.
如果可以的话,我需要你的一点帮助。如果出现超过 1 个,我需要 php 中的正则表达式来删除多个新行和多余的空格。
for example Hi this is a test code
------------------> 上面转换成
Hi this is a test code
利用 :
echo preg_replace("/(^\s+|\s+$)/m","\r\n",$text);
参考:链接:
如何使用 PHP 或正则表达式在每一行的开头和结尾修剪空白