title: Regular expression for validating math equation
body: <p>I'm trying to build a regex that validates a math equation.  The equation itself is very simple, I'm looking to make an English readable equation, that I will later return as true or false.  An example would be like so.</p>
  <blockquote>
  <p>((1 and 2) or 3)</p>
  </blockquote>
  <p>In this example, I will swap out any numbers with either true, or false.  I will also replace, &quot;and&quot; with &quot;&amp;&amp;&quot; and &quot;or&quot; with &quot;||&quot; in order to run the equation using PHP.  The response to this will ultimately be either true, or false.</p>
  <p>An example final equation would look something like this:</p>
  <blockquote>
  <p>((true &amp;&amp; true) || true)</p>
  </blockquote>
  <p>Here are some more examples of what should be considered valid.</p>
  <blockquote>
  <p>(1 or 2 or 3)</p>
  <p>((1 and 2 and 3) or (4 and 5))</p>
  </blockquote>
  <p>So, my question comes in two parts.</p>
  <ol>
  <li>Is it possible to create a regex expression to validate all possible valid equations?  One big road block for me is understanding how I could validate that all opening &quot;(&quot; also have the closing &quot;)&quot;.</li>
  <li>Is it advisable to use a regex expression in order to validate client side in this circumstance?  I am already able to validate the expression using AJAX and PHP, so am I just overthinking this?</li>
  </ol>