简体   繁体   中英

Finding functions with default value in javascript

I am having error when uploading my website on heroku as having default values in function.
Until now I have used default value lots of times and they are in 50000 column javascript file and I cant really find all of them. So I tried to find all functions with default values in sublime using regex. I tried this regular expression.

function.*\(.*\=.*\)

But it's finding this kind of string(which is not default value function).

Function(e)) return Q.grep(t, function(t, i) { return !!e.call(t, i, t) !== n })

Sample function to be searched

var abc = function(x , y = 1)
function abc(x , y = 1)

Please help, I am new to regular expression and it's really difficult to find answer.

尝试使用此正则表达式function[a-zA-Z ]*\\([a-zA-Z \\,]+[a-zA-Z ]*[=] ,它将与具有默认参数的函数匹配,而与参数数量无关。希望对您有所帮助。

试试这个function[\\s\\w]*\\([\\w\\s\\d,]*[\\w\\s]+=[\\w\\d\\s'",]*\\) 。默认值可能是字符串,函数也可能具有名称: var abc = function some_name (x , y = 1, z = "string", z_z) { var = 1

function\([^)]+\)

and take refernce from this:

Regular expression to find all function calls with parameters in VS2010

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM