I am trying to get a function name from a string in javascript.
Let's say I have this string:
function multiply($number) {
return ($number * 2);
}
I am using the following regex in javascript:
/([a-zA-Z_{1}][a-zA-Z0-9_]+)\(/g
However, what is selected is multiply(
. This is wrong. What I want is the word multiply
without the the (
, though the regex should keep in mind that the function name must be attached an (
.
I can't get this done. How can I make the proper regex for this? I know that this is not something I really should do and that it is quite error sensitive, but I still wanna try to make this work.