title: Optional capture group part
body: <p>I have this regex pattern:</p>
  
  <pre><code>[^-]+-(.+)[^\d](.+)-(.*?)-.*(\d+).*-([\w]+-[\w]+-[^-]+)-(\d+-\d+)-(.+)\.
  </code></pre>
  
  <p>That needs to match both these cases</p>
  
  <pre><code>Data Location 1 - many many words 201808206566 - many words - 010114-INL-USD-B087834-2018-08-Bill.PDF
  
  Data Location 1 - many many words 201808206565 - many words - 010115-INL-B087845-2018-08-Bill.PDF
  </code></pre>
  
  <p>As is, this matches the first case and not the second. And I get the opposite result by removing one instance of <code>[\w]+-</code> from within the 5th capture group, this is because the first case contains INL-USD-B087834, which has an additional data block in it. How can I make the second instance optional? </p>