0

I am trying to find function names in source codes but not in function declarations. Let's say we have the following source code:

function foo()
{
 if ( ! foo5() )
  foo3(bar("string"), foo2());
 else
  foo3(bar("string"));
}

function foo4()
{
 if (!foo5())
  bar2(bar("string"), foo2());
 else
  bar2(bar("string"));
}

I want to extract foo5,foo3,bar,foo2,bar2 but not foo and foo4

I tried the following regex with no luck

(?<!function )(\w+)\(

All words that have open parenthesis but not started with function

HadiRj
  • 1,015
  • 3
  • 21
  • 41

1 Answers1

3

Try this regex:

(?<!function )(\b\w+)\(

As far as I can see it's working for your example.

Paco H.
  • 2,034
  • 7
  • 18