title: check if a string has only some specific words
body: <p>i'm using a string with brackets, numbers and logical operators (AND, OR, NOT)
  i want to validate my string by checking if user enters the correct operators.</p>
  
  <p>example:</p>
  
  <pre><code>(12 AND 13)        //correct
  (12 BAND 13)       //incorrect
  (12 AND 13 OR 14)  //correct
  (12 DNA 13 OR 14)  //incorrect
  </code></pre>
  
  <p>I want to validate this string in either javascript or php,<br>
  so a REGEX or a pregmatch would do the job.</p>
  
  <p>EDIT:-</p>
  
  <p>there can be any number of operators in a string.. Plus nested brackets can also exist, like </p>
  
  <pre><code>(11 AND 12 AND 13 OR 14 NOT 15)  //correct
  ((12 AND 13) NOT 14)             //correct
  </code></pre>