In JavaScript, I am trying to match all occurrences of the following
initChart('something');
initMap('another');
initChart();
initMap();
UNLESS it is preceded by the word 'function', meaning, do not match
function initChart(param) { ... }
function initMap(param) { ... }
Basically I need to strip out all occurrences that invoke the function, while leaving the function definition in tact. I got this far
/init.*(.*)/i
This is what my script looks like to strip out matches:
var scriptRegex = /init.*(.*)/i;
while (scriptRegex.test(responseHTML)) {
responseHTML = responseHTML.replace(scriptRegex, "");
}
But I'm stuck at how to tell it "only if it is NOT preceded by the word 'function'