有一个像这样的字符串:
"*this* not that"
我可以选择*这个*
\*(.*?)\*
但我不能只得到这个。
我想要实现的目标是用新字符串替换 -this- 。最简单的方法是什么?
最佳答案
你可以尝试:
"*this* not that".replace(/\*.*\*/,'*new_string*');
//"*new_string* not that"
关于javascript - 提取两个字符之间的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35769779/