我有一个这样的字符串
This is\' it
我希望它看起来像这样
This is' it
我所做的一切似乎都不起作用
> "This is\' it".replace(/\\'/,"'");
'This is\' it'
> "This is\' it".replace("'",/\\'/);
'This is/\\\\\'/ it'
> "This is\' it".replace("\'","'");
'This is\' it'
> "This is\' it".replace("'","\'");
'This is\' it'
更新:这有点难以理解,但我将示例字符串放在一个类似的数组中。
> ["hello world's"]
[ 'hello world\'s' ]
它会像这样自动发生:
> var a = ["hello world's"]
undefined
> a
[ 'hello world\'s' ]
> a[0]
'hello world\'s'
> console.log(a[0])
hello world's
undefined
> console.log(a)
[ 'hello world\'s' ]
undefined
>