gpt4 book ai didi

javascript - 如何使用 javascript string.replace

转载 作者:行者123 更新时间:2023-11-28 17:38:26 25 4
gpt4 key购买 nike

我正在尝试替换:

The quick fox jumped over "tree"

与:

The quick fox jumped over "wall"

我已经尝试过这个:

var str = 'The quick fox jumped over "tree"';
str.replace(/"tree"/g, '"wall"');

替换没有发生。请帮忙

最佳答案

您只需在替换字符串后保存它即可。

var str = 'The quick fox jumped over "tree"'; 
str = str.replace('"tree"', '"wall"');
console.log(str);

关于javascript - 如何使用 javascript string.replace,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48555054/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com