Removing invalid characters in JavaScript

后端 未结 3 857
一个人的身影
一个人的身影 2020-12-29 05:30

Can someone provide a regular expression to search and replace illegal characters found

Example, removing �

I am not sure how many types of \'illegal\' char

3条回答
  •  梦谈多话
    2020-12-29 06:13

    Try this, it will work for all unexpected character like ♫ ◘ etc...

    dataStr.replace(/[\u{0080}-\u{FFFF}]/gu,"");
    

提交回复
热议问题