且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Apps脚本正则表达式-不区分大小写

更新时间:2023-02-15 18:38:23

如果我记得,我相信您可以创建一个新的regexp对象并在此处使用exec.

If I recall, I believe you can create a new regexp object and use exec here.

var re = new RegExp('\\bmicssys\\b','gi');

var match;
var bodyElement = DocumentApp.getActiveDocument().getBody();
while (match = re.exec(bodyElement)) {
   // match[0] will return the found results
}

注意:您可能必须使用getText()以文本字符串的形式检索元素的内容,然后进行匹配.

Note: You may have to use getText() to retrieve the contents of the element as a text string and then match against.