I am trying to do a case insensitive find&replace in Google Docs using their Apps Api. I can't find a function that allows me to set this option (like in Slides or the User Interface) so will have to use body.replaceText() . Additionally I want use a variable to set the find string, but can't even get it to work with an explicitly given value.
I have tried different versions without success:
var findValue="foo";
var replaceValue="bar"
1) var regex = new RegExp('\\bfindValue\\b','gi');
body.replaceText(regex,replaceValue);
2) var regex="/(\\b)"+findValue+"(\\b)/gi";
body.replaceText(regex,replaceValue);
3) body.replaceText("/(\\b)"+findValue+"(\\b)/gi",replaceValue);
4) body.replaceText(/foo/gi,"bar");
Not even nr 4) finds Foo or foo in the text. Any suggestions?