gpt4 book ai didi

javascript - 字符串将双引号替换成大括号

转载 作者:数据小太阳 更新时间:2023-10-29 05:00:46 25 4
gpt4 key购买 nike

<分区>

如何将所有双引号替换为左大括号和右大括号。

let str = "This" is my "new" key "string";

我试过这个正则表达式

str.replace(/"/,'{').replace(/"/,'}')

但我最终得到了这个:

{This} is my "new" key "string"

这里只有第一个词在改变,但我想改变所有的词。我希望结果是:

{This} is my {new} key {string}

提前致谢。

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