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 }";

Extracted:

$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 almost 7 years ago

1 answer

0
points

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

Answered almost 7 years ago by Abinadi Ayerdis