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

后端 未结 8 1557
终归单人心
终归单人心 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:56

    Since [^a-z0-9] character class contains all that is not alnum, it contains white characters too!

     text.replace(/[^a-z0-9]+/gi, " ");
    

提交回复
热议问题