I'm trying to remove all type casts from a js file.
The current (not-working) regex I have is:
/(?!new\s+&?!function\s+)\w+\((.+)\)/gi
Basically I want anything like Class(var) but not new Class(arg)
or function Func(arg)
Thanks!
I'm trying to remove all type casts from a js file.
The current (not-working) regex I have is:
/(?!new\s+&?!function\s+)\w+\((.+)\)/gi
Basically I want anything like Class(var) but not new Class(arg)
or function Func(arg)
Thanks!
s = "Basically I want anything like Class(var) but not new Class(arg) or function Func(arg)"
re = /(?:(?!new|function)\b\S+|^|[^\w\s])\s*\b([A-Z]\w*\s*\(.*?\))/g
for (var match; (match = re.exec(s));) { alert(match[1]); }
produces
Class(var)
but will only match correctly if there are no nested parentheses in the actual parameter list. To generally match a function call is not possible using regular expressions since regular grammars can't handled nested parenthetical groups.