title: RegEx: If first character is '%' or alphanumeric then
body: <p>in nodejs, I have to following pattern</p>
  <pre><code>(/^(&gt;|&lt;|&gt;=|&lt;=|!=|%)?[a-z0-9 ]+?(%)*$/i
  </code></pre>
  <p>to match only alphanumeric strings, with optional suffix and prefix with some special characters. And its working just fine.</p>
  <p>Now I want to match the last '%' only if the first character is alphanumeric (case insensitive) or also a %. Then its optionally allowed, otherwise it should not match.</p>
  <p>Example:</p>
  <p><strong>Should</strong> match:</p>
  <pre><code>&gt;test
  !=test
  &lt;test
  &gt;=test
  &lt;=test
  %test
  test
  %test%
  test%
  </code></pre>
  <p>Example which should <strong>not</strong> match:</p>
  <pre><code>&lt;test% &lt;-- its now matching, which is not correct
  &lt;test&lt; &lt;-- its now **not** matching, which is correct
  </code></pre>
  <p>Any Ideas?</p>