How to replace an apostrophe in a string in Javascript?

前端 未结 3 640
死守一世寂寞
死守一世寂寞 2021-02-07 20:04

Given a string in Javacript, such as

var str = \"this\'s kelly\";

I want to replace the apostrophe (\') with another character. Here is what I\

3条回答
  •  误落风尘
    2021-02-07 20:23

    str = str.replace("'", "A");

    Your running the function but not assigning it to anything again so the var remains unchanged

提交回复
热议问题