How do I replace single quotes with double quotes in JavaScript?

后端 未结 7 665
遥遥无期
遥遥无期 2021-02-01 02:10

The following code replaces only one single quote:

7条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-01 02:43

    You can use a RegExp with the global flag g and all quotes will replaced:

    var b = a.replace(/'/g, '"');
    

提交回复
热议问题