title: CAtlRegExp for a regular expression that matches 4 characters max
body: <h2>Short version:</h2>
  <p>How can I get a regex that matches a@a.aaaa but not a@a.aaaaa using <a href="http://msdn.microsoft.com/en-us/library/k3zs4axe(VS.80).aspx" rel="nofollow noreferrer">CAtlRegExp</a> ?</p>
  <hr />
  <h2>Long version:</h2>
  <p>I'm using CAtlRegExp <a href="http://msdn.microsoft.com/en-us/library/k3zs4axe(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/k3zs4axe(VS.80).aspx</a> to try to match email addresses. I want to use the regex</p>
  <pre><code>^[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$
  </code></pre>
  <p>extracted from <a href="http://www.regular-expressions.info/email.html" rel="nofollow noreferrer">here</a>.
  But the syntax that CAtlRegExp accepts is different than the one used there. This regex returns the error REPARSE_ERROR_BRACKET_EXPECTED, you can check for yourself using this app: <a href="http://www.codeproject.com/KB/string/mfcregex.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/string/mfcregex.aspx</a></p>
  <p>Using said app, I created this regex:</p>
  <pre><code>^[a-zA-Z0-9\._%\+\-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z]$
  </code></pre>
  <p>But the problem is this matches a@a.aaaaa as valid, I need it to match 4 characters maximum for the op-level domain.</p>
  <p>So, how can I get a regex that matches a@a.aaaa but not a@a.aaaaa ?</p>