function indexingAllMatches() {
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
var re = /[3012]/g; // regular expression
var str = body.getChild(0).asText().getText();
// str = "The 1author lives 2in Iowa, 1USA."
while ((match = re.exec(str)) != null) {
Logger.log("match found at " + match.index);
}
// expected return = 4,18,28
}
沒有留言:
張貼留言