Replace unicode space characters

前端 未结 4 598
轮回少年
轮回少年 2020-12-11 05:07

I need to replace the unicode characters defined on here

I have got this so far but it seems to remove all space including standard spacebar ones:

va         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-11 05:34

    I guess you should use the escape sequence for spaces (15.10.2.12 of the norm) which is \s, and that you want to replace multiple spaces by a single one :

    str= str.replace(/\s+/g,' ') ;
    

提交回复
热议问题