I have a script that takes data from a gsheet and replaces placeholders on gdoc. I am looking to optimise the script by using arrays instead.
This is a sample of my
I believe you can optimize your code by using the appropriate method(s) to preserve the text format of your Google sheet values.
Look into using the following method(s) of class Range from SpreadsheetApp service.
Method getDisplayValue() returns the displayed value of the cell in the range. The value is a String. The displayed value takes into account date, time and currency formatting, including formats applied automatically by the spreadsheet's locale setting. Empty cells return an empty string.
This should optimize your code by removing the necessity of regex. If I didn't understand your issue correctly, please leave a comment.
References: