title: Regex allows for repeating the pattern when I don't want it to
body: <p>I'm trying to take a query parameter and verify if the syntax provided by the user is correct. Regex seems like the best choice for this, but I'm having trouble making it so the pattern doesn't allow for repeating itself.</p>
  <p>The pattern I came up with is:</p>
  <pre><code>(^(\w+)(=|!=|&gt;=|&gt;|&lt;=|&lt;|~)((')(.*)('))(\s(AND|OR)\s)(\w+)(=|!=|&gt;=|&gt;|&lt;=|&lt;|~)((')(.*)('))$)
  </code></pre>
  <p>The syntax provided by the user should to be:</p>
  <blockquote>
  <p>[field][predicate][single quote][value][single quote][white space][logical operator][white space][field][predicate][single quote][value][single quote]</p>
  </blockquote>
  <p>Where:</p>
  <ol>
  <li>field is [any word]</li>
  <li>predicate is [= | != | &gt;= | &gt; | &lt;= | &lt; | ~]</li>
  <li>logical operator is [AND | OR (with a space on both sides)]</li>
  <li>value is [any word wrapped by single quotes]</li>
  </ol>
  <blockquote>
  <p>An example looks like this: <strong>field1='value1' OR field2='value2'</strong></p>
  </blockquote>
  <p>The problem I am having is that the pattern I created allows for things like this:</p>
  <blockquote>
  <p>field1='value1' OR field2='value2field1='value' OR field2='value2'' [<strong>This shouldn't work but does</strong>]</p>
  <p>field1='value1' OR field2='value2 field1='value' OR field2='value2'' [<strong>This shouldn't work but does</strong>]</p>
  <p>field1='value1' OR field2='value2' AND field3='value3' OR field4='value4'' [<strong>This shouldn't work but does</strong>]</p>
  </blockquote>
  <p>Any help would be appreciated making it so the pattern doesn't match if it repeats.</p>