【发布时间】:2021-01-05 07:36:28
【问题描述】:
我想用正则表达式得到结果
var text = "\"1test2test3\"test123test45test\"67test89\"";
text.replaceAll(/\"(.*)\"/g, "boom");
boom
但我想要
var text = "\"1test2test3\"test123test45test\"67test89\"";
text.replaceAll(????, "boom");
"\"1test2test3\"boom123boom45boom\"67test89\"";
【问题讨论】:
-
可能最简单和最易读的方法是首先拆分字符串,然后只处理您实际想要替换的子字符串部分。
标签: javascript html regex