How to Regex-replace multiple
tags with one
tag?

后端 未结 5 1239
误落风尘
误落风尘 2020-11-29 07:57

I want

to turn into

What\'s the pattern for this with regex?

Note: The

5条回答
  •  醉梦人生
    2020-11-29 08:12

    The answer from @FtDRbwLXw6 is great although it does not account for   spaces. We can extend this regex to include that as well:

    $html = preg_replace('#(
    \s*( )*)+#', '
    ', $html);

提交回复
热议问题