Replace multiple
's with only one

前端 未结 9 2106
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-01 12:55

How do I use JavaScript to detect




to become one


?

I trie

9条回答
  •  余生分开走
    2021-02-01 13:29

    Simpler:

    var newText = oldText.replace(/(){3,}/gi, '
    ');

    This will allow optional tag terminator (/>) and also spaces before tag end (e.g.
    or
    ).

提交回复
热议问题