I am trying to do something really really basic. It's just a search and replace using this function, which uses some proprietary Regex I never used before.
https://developers.google.com/apps-script/reference/document/text#replaceText(String,String)
What I am trying to accomplish is simple, run through the whole document and replace placeholders with text. The string to match is in this format:
#replace this please#
By using this pattern:
(\W|^)#replace this please#(\W|$)
copied from the Google Examples found here (https://support.google.com/a/answer/1371417?hl=en)
It works absolutely fine for one exception which bugs me out. If I have 2 or more placeholders on the same line, it won't match any of them.
So if I have something like this:
#replace me please# and some normal text here #replace me too#
None of those 2 will be matched. I am assuming my expression doesn't take this into account, but the documentation is very hard to find for their implementation of regular expressions.
Can anybody help please?


(\W|^)#replace this please#(\W|$)? If not, can we please see it. Can we also see a real sample line that is tripping you up?