【发布时间】:2017-10-03 18:18:29
【问题描述】:
在我的代码中,当我尝试将“don't”替换为“do not”时,它不起作用,但当我使用常规单词时,它会起作用。我试图用“不要”来逃避。 有没有特殊的方法来转义谷歌应用脚本中的字符?
//Sidebar.html
function doWordReplace(value) {
if(value.checked) {
google.script.run.withSuccessHandler(print).wordReplace("don't");
}
else {}
}
//Replace.gs
function wordReplace(findMe) {
var text = DocumentApp.getActiveDocument().getBody().editAsText();
text.replaceText(findMe, "do not");
return "replacement successful";
}
【问题讨论】:
标签: javascript regex string google-apps-script