function searchAndColorInRed() {
var doc = DocumentApp.getActiveDocument();
var textToHighlight = new RegExp('\(\d{0,4}\)');
var highlightStyle = {};
highlightStyle[DocumentApp.Attribute.FOREGROUND_COLOR] = '#FF0000';
var paras = doc.getParagraphs();
var textLocation = {};
var i;
for (i=0; i<paras.length; ++i) {
textLocation = paras[i].findText(textToHighlight);
if (textLocation != null && textLocation.getStartOffset() != -1) {
textLocation.getElement().setAttributes(textLocation.getStartOffset(),textLocation.getEndOffsetInclusive(), highlightStyle);
}
}
};
有这个功能来搜索括号中的数字,如(6406)但是着色不起作用..我不知道为什么,有人可以帮我吗?