I'm trying to figure out how to find certain characters in a Google Doc. For example how to search for a blank space Text.findText(" ") throws an exception. Text.findText("\s") doesn't find anything. And now Text.findText("^") gives a weird exception "We're sorry, a server error occurred. Please wait a bit and try again.". I've also tried Text.findText("\^") but get the same weird exception. Normally you can just put a text string like Text.findText("find this") and it works. How to properly put regex expressions in findText()?
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/4a7ad6ed-1a9f-484d-b462-feed71539254%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
var searchValue = "\\s|\\^";var doc = DocumentApp.getActiveDocument();var body = doc.getBody();var s = body.findText(searchValue);while (s) { var text = s.getElement().asText(); Logger.log(text.getText()) var s = body.findText(searchValue, s);}