replace替换$符号

const str ='xxxx$xx$xx'

str.replace(/\$/g,'') // "xxxxxxxx"

 

str.replaceAll('$','')   // "xxxxxxxx"

  

str.replaceAll(/\$/g,'')  //  "xxxxxxxx"

   备注:有的浏览器(safari)不兼容replaceAll,因此只能采用正则的方式。

posted on 2021-08-02 14:00  稳住别慌  阅读(463)  评论(0)    收藏  举报