Replace all non Alpha Numeric characters, New Lines, and multiple White Space with one Space

后端 未结 8 1541
终归单人心
终归单人心 2021-01-29 20:24

I\'m looking for a neat RegEx solution to replace

  • All non Alpha-Numeric Characters
  • All NewLines
  • All multiple instances of white space
8条回答
  •  野的像风
    2021-01-29 20:41

    Jonny 5 beat me to it. I was going to suggest using the \W+ without the \s as in text.replace(/\W+/g, " "). This covers white space as well.

提交回复
热议问题