title: Add optional part in python regular expression
body: <p>I want to add an optional part to my python expression:</p>
  
  <pre><code>myExp = re.compile("(.*)_(\d+)\.(\w+)")
  </code></pre>
  
  <p>so that
  if my string is abc_34.txt, result.group(2) is 34
  if my string is abc_2034.txt, results.group(2) is still 34</p>
  
  <p>I tried <code>myExp = re.compile("(.*)_[20](\d+)\.(\w+)")</code></p>
  
  <p>but my results.groups(2) is 034 for the case of abc_2034.txt</p>
  
  <p>Thanks F.J.</p>
  
  <p>But I want to expand your solution and add a suffix.</p>
  
  <p>so that if I put abc_203422.txt, results.group(2) is still 34</p>
  
  <p>I tried "(.*)_(?:20)?(\d+)(?:22)?.(\w+)")
  but I get 3422 instead of 34</p>