2
我想使用findText(searchPattern)方法在google文檔中查找字符串。我是searchPattern是正則表達式,如下列:方法findText與正則表達式
var doc = DocumentApp.getActiveDocument().getBody();
var textToHighlight = '';
textToHighlight = new RegExp( "this");
textLocation = doc.findText(textToHighlight);
但它給了我下面的錯誤,而不是搜索的文本:
谷歌Apps腳本:參數不能爲空:提示
我閱讀Text類中findText方法的文檔。在這裏它將searchPattern指定爲字符串。有沒有其他的選擇使用正則表達式來查找文本。
謝謝