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
  • 68,849
  • 28
  • 172
  • 209

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
  • 20,614
  • 3
  • 37
  • 40