grunt-text-replace icon indicating copy to clipboard operation
grunt-text-replace copied to clipboard

replace with matching parentheses

Open dtracers opened this issue 9 years ago • 0 comments

hello I would like to use regular expression to replace a specific function call with something else.

specifically I made a function called isUndefined which returns true if the input is not defined. ex:

if (isUndefined(PARAM)) {
 // do blah

but it appears that some browsers do not like this if PARAM has never been mentioned before for such reasons I would like to add a build step to replace the function call with typeof PARAM === "undefined"

the problem is that PARAM could contains parenthesis and I need it to match to the end of the matching parenthesis.

Regular expressions does have a recursive element to it. but that does not exist in javascript apparently. So I was wondering if you had any advice on how to accomplish using your tool

Example of success:

isUndefined(funcThatMayReturnUndefined())

// changes to

typeof funcThatMayReturnUndefined() === "undefined"

dtracers avatar Apr 04 '15 02:04 dtracers