title: Java detect if a string is a valid JS script
body: <p>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 : </p>
  
  <pre><code>if(jsString.trim().endsWith(";")) {
  //Evaluate with Rhino
  }
  </code></pre>
  
  <p>Is there a better way for figure out if a string is a valid JS script ?</p>
  
  <p>What is the best way ?</p>