How to replace curly quotation marks in a string using Javascript?

前端 未结 3 470
挽巷
挽巷 2020-12-05 07:02

I am trying to replace curly quotes:

str = \'“I don’t know what you mean by ‘glory,’ ” Alice said.\';

Using:

str.replace(/[         


        
3条回答
  •  無奈伤痛
    2020-12-05 07:50

    It doesn't work because you're trying to replace the ASCII apostrophe (or single-quote) and quote characters with the empty string, when what's actually in your source string aren't ASCII characters.

    str.replace(/[“”‘’]/g,'');
    

    works.

提交回复
热议问题