How to Regex-replace multiple
tags with one
tag?

后端 未结 5 1248
误落风尘
误落风尘 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:24

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

    This will catch any combination of
    ,
    , or
    with any amount or type of whitespace between them and replace them with a single
    .

提交回复
热议问题