Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace with matching parentheses #40

Open
dtracers opened this issue Apr 4, 2015 · 0 comments
Open

replace with matching parentheses #40

dtracers opened this issue Apr 4, 2015 · 0 comments

Comments

@dtracers
Copy link

dtracers commented Apr 4, 2015

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant