I'm trying to define a new Google Sheet formula using Google Script (which have Javascript grammar if I understand it well).
so, given myformula
=MYFORMULA(A1;A2;A3;A4;A5;A6;B7)
I found how to extract all the arguments using this answer
function myFormula(arguments)
{
var activeRange = SpreadsheetApp.getActiveRange();
//var activeSheet = activeRange.getSheet();
var formula = activeRange.getFormula();
var extr = formula.match(/\(([^()]+)\)/).pop();
return extr;
}
--> extr = "A1;A2;A3;A4;A5;A6;B7"
i would like to extract the list of all arguments (assuming ";" as separator) and eventually discard the last one, obtaining something like
extr = ["A1", "A2", "A3", "A4", "A5", "A6"];
How can I do with a regex? Single regex or with iteration? (number of items is variable)