Google Apps Script/javascript Search And Replace With Regex Not Working
Solution 1:
As shown in the replaceText documentation, it expects a string
on both parameters. The first one will automatically generate a RegExp
for you. Therefore you can use a regular expression, but due to this syntax limitation, you can not pass RegExp
flags to it (in your example the gim
).
Also, since the second parameter also only accepts a string, you can not inform a function, which is what you'd need to make a proper toUpperCase
(which is wrong in your example even if using javascript built-in string.replace function).
And from tests I just made, replacement string patterns using "$&" or "$#" don't work either.
So, to achieve what you're looking for you'll have to implement this search-and-replace yourself (possibly using findText to help on the "search" part).
Post a Comment for "Google Apps Script/javascript Search And Replace With Regex Not Working"