Replace multiple
's with only one

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

How do I use JavaScript to detect




to become one


?

I trie

9条回答
  •  别那么骄傲
    2021-02-01 13:14

    I would go with this:

    $('body').html($('body').html().replace(/(\W?()+)+/g,"
    "));

    However, after reading the comments in another post here I do consider that you should try to avoid doing this in case you can correct it in the back end.

提交回复
热议问题