2

I want to detect if a string is a valid javasript code for pass it for the evaluation of rhino engine, now i'm assuming that the string is a javascript script with this simple statement :

if(jsString.trim().endsWith(";")) {
//Evaluate with Rhino
}

Is there a better way for figure out if a string is a valid JS script ?

What is the best way ?

aleroot
  • 71,077
  • 30
  • 176
  • 213

1 Answers1

1

You could utilise something like: http://code.google.com/p/jslint4java/

In any case, you want to run the string through JSLint.

BGerrissen
  • 21,250
  • 3
  • 39
  • 40