I've encountered some problems using Regex (extract / match) in Google Sheets Script, but managed to handle artificially by referencing cell that contains my Regex (it actually works better in this way to me, cuz I can quickly modify regex from cell).
function fillL()
{
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
ss.getRange("L4").setFormula("=REGEXMATCH(B4,$L$3)");
var lr = ss.getLastRow();
var fillDownRange = ss.getRange(4,12,lr-3);
ss.getRange("L4").copyTo(fillDownRange);
}
But this same trick doesn't work for a more complex formula as the one below. I've read I need to concat strings/variables with + , and tried doing it but I still get the 'Syntax error: SyntaxError: missing ) after argument list line: 98 file: Code.gs'
function fillN()
{
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
ss.getRange("N4").setFormula("=IF((ISNUMBER(MATCH(REGEXEXTRACT(A4,$N$3),Sheet8!$A$1:$A,0))=TRUE),INDEX(Sheet8!$B$1:$B,MATCH(REGEXEXTRACT(A4,$N$3),Sheet8!A:A,0)),"No Match")");
var lr = ss.getLastRow();
var fillDownRange = ss.getRange(4,14,lr-3);
ss.getRange("N4").copyTo(fillDownRange);
}
I tried to concat the only string in the formula there at the end ( + "No Match"), but I still get the error, can't figure out if smth else is wrong?! This is the regex referenced in the cell that I'm using, if it helps. Thanks