I have a String and want to replace it with other String as given in mssqlFunctions object.
var mssqlFunctions = {
DateDiff: "DATEDIFF",
Abs: "ABS",
y: 'year',
m: 'minute'
};
My String is: DateDiff(m, Abs(23)[Emy()])
This is my code to replace String
var regularExpression = new RegExp(Object.keys(mssqlFunctions).join("|"),"gi");
formula = formula.replace(regularExpression, function(matched){
return mssqlFunctions[matched];
});
So it gives Output as DATEDIFF(minute, ABS(23)[Eminuteyear()])
But I don't want to replace string which is in []
So the Output which I want is
DATEDIFF(minute, ABS(23)[Emy()])