title: How to limit occurrence of substring in Regular Expression to one?
body: <p>I have this regex:</p>
  
  <pre><code>/\A((\{YY\})?[-_]*(\{MM\})?[-_]*(\{DD\})?[-_]*(\{N{4,8}\})|[A-Za-z])*\z/
  </code></pre>
  
  <p>that matches values such as:</p>
  
  <pre><code>{YY}-{MM}-{DD}-{NNNN}
  </code></pre>
  
  <p>Is there a way to limit the number of substrings contained within <code>{N</code> and <code>N}</code> to one, so that the following string would be invalid?</p>
  
  <pre><code>{YY}-{MM}-{DD}-{NNNN}-{NNNNNN}
  </code></pre>
  
  <p>Thanks for any help.</p>