I have to extract defined variable and function names from a js code passed as a text. Example:

$js_code = " var MyVar1 = 'val1'; \n var MyVar2 = 'val2' ; \n function MyFunc() { some code }";


$js_vars = array("MyVar1 ", "MyVar2 ");
$js_func = array("MyFunc");
  • This was also asked and answered at StackOverflow: http://stackoverflow.com/questions/2388173/could-you-recommend-me-a-server-side-javascript-parser BPartch over 7 years ago

1 answer


So to paraphrase the StackOverflow answer, check out Aptana Jaxer and jParser.

Answered over 7 years ago by Abinadi Ayerdis