【发布时间】:2012-06-11 12:08:30
【问题描述】:
我想将“\cite{foo123a}”替换为“[1]”并向后替换。到目前为止,我能够用以下命令替换文本
body.replaceText('.cite{foo}', '[1]');
但我没有设法使用
body.replaceText('\cite{foo}', '[1]');
body.replaceText('\\cite{foo}', '[1]');
为什么?
我根本无法进行反向转换
body.replaceText('[1]', '\\cite{foo}');
这将只替换“1”而不是 [],这意味着 [] 被解释为正则表达式字符集,转义它们将无济于事
body.replaceText('\[1\]', '\\cite{foo}');//no effect, still a char set
body.replaceText('/\[1\]/', '\\cite{foo}');//no matches
文档说明
不完全支持 JavaScript 正则表达式功能的子集,例如捕获组和模式修饰符。
我能否在某处找到有关受支持和不支持的内容的完整说明?
【问题讨论】:
标签: google-apps-script google-docs