I am trying to extract comma separators from excel if condition, my question is if my approach is adequate or if there’s a better way to do so?
it’ll be very nice if it works with multiple recursive if conditions.

=if(match(“CELL1”, “00002*”) and match(“CELL2”, “0005*”), ‘TEXT1’, ‘TEXT2’)

var c = `=if(match("CELL1", "00002*") and match("CELL2", "0005*"), 'TEXT1', 'TEXT2')`;
function getParameterPlace(formula) {
var pos = [];
var original_formula = formula;
var len = 0;
formula.replace(/\=if\s*?\((.*?)[^\)]*$/gi, function(a,b) {
var len = a.length - b.length
formula = b.substring(0, b.length-1);
formula = formula.replace(/\((.*?)\)/g, function(c,d) {
return 'X'.repeat(c.length)
});
var thenPOS = formula.indexOf(',') + len;
var elsePOS = formula.lastIndexOf(',') + len;
pos = [thenPOS, elsePOS];
});
return pos;
}
console.log(getParameterPlace(c))

Javascript I’m terrible, but I’m very good at Excel, I just didn’t understand your question.
Here in Brazil, Excel uses some different nomenclatures, but the IF formula operates as follows
=if(condition, value if true, value if false)
Of course there are combinations of formulas

Its syntaxes are:
=MATCH( lookup_value ; lookup_array ; [match_type] )
Lookup_value: Enter the value to be searched for, this will be the value that will be searched within the list selected in “lookup_array”;
Lookup_array: Select a column, row or matrix to search for the searched value;
[Match_type]:
1 = Finds the largest value less than or equal to the value sought;
0 = Finds the first value exactly equal to the value sought;
-1 = Finds the smallest value greater than or equal to the value sought;

It seems to me that you are wanting to create a system to refine searches, correct?

If I were to write this formula in Excel I would do it like this: =if(e((match(“cell1”,"00002")),(match(“cell2”,"0005"))),‘text1’,‘text2’)**

However, the logic and use of conditions in the excel formula seem to be wrong.

hello @gilmar
Thanks again, I think I have not explained well, I am actually looking to convert excel syntax to sql syntax, for which I need to extract the proper comma positions for each “THEN” and “ELSE”, the issue is that commas can appear within other functions such as POWER(2,2) or CONCAT(‘A’, ‘B’) etc.
I hope I have explained well this time