title: Locate folders with find that match a regular expression with optional groups
body: <p>I am trying to <code>find</code> files within a hierarchy whose paths contain language codes such as <code>de-DE</code> and <code>fr</code>.</p>
  
  <p>I am using:</p>
  
  <pre><code>find srcfldr -regex "*/[a-z][a-z](-[A-Z][A-Z])?*" -regextype posix-extended
  </code></pre>
  
  <p>but it is not finding folders such as <code>/e/myfolder/srcfldr/langs/de</code>.</p>
  
  <p>I've also tried:</p>
  
  <pre><code>find srcfldr -wholename "*/[a-z][a-z](-[A-Z][A-Z])?*" -regextype posix-extended
  </code></pre>