gpt4 book ai didi

javascript - 提取两个字符之间的文本

转载 作者:行者123 更新时间:2023-12-03 07:32:16 25 4
gpt4 key购买 nike

有一个像这样的字符串:

"*this* not that"

我可以选择*这个*

\*(.*?)\*

但我不能只得到这个

我想要实现的目标是用新字符串替换 -this- 。最简单的方法是什么?

最佳答案

你可以尝试:

"*this* not that".replace(/\*.*\*/,'*new_string*');
//"*new_string* not that"

关于javascript - 提取两个字符之间的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35769779/

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