How to Regex-replace multiple
tags with one
tag?

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

    You could use s/(
    )+/
    /
    , but if you are trying to use regex on HTML you are likely doing something wrong.

    Edit: A slightly more robust pattern you could use if you have mixed breaks:

    /()+/

    This will catch
    and
    as well, which might be useful in certain cases.

提交回复
热议问题