我花了几个小时研究了几十种不同的解决方案,但没有一个奏效。我在 php 字符串中接收到 textarea 的内容,我想删除超过一个空行的任何内容。
Example ok
Hi how are you,
// one blank line here so ok to keep
Not too bad thanks
Example not ok
hi how are you
// two lines (or more) here so we remove one and keep the other
not too bad thanks
有人知道要使用的正确 preg_replace 吗?请注意,我不想修改数据(请不要使用 nl2br()),因为我更容易保持原始数据(ios 支持)。