title: python image sequence file pattern regex
body: <p>A file in an image sequence typically looks something like this: image.001.png, where "001" is the frame number of this image. I am trying to construct a sequence pattern that will capture in groups: 1) everything before the frame number, 2) the frame number, 3) the extension.</p>
  
  <p>I'm totally new to regex and I'm having trouble creating a pattern which will work in every possible case I can think of. So far here are the possible cases I know of, and what I would like to capture in parentheses below:</p>
  
  <pre><code>img123.png
  (img) (123) (png)
  
  img.123.png
  (img.) (123) (png)
  
  img_v01_1234.png
  (img_v01_) (1234) (png)
  
  img01_123.png
  (img01_) (123) (png)
  
  img.001.123.png
  (img.001.) (123) (png)
  
  img 001.12.png
  (img 001.) (12) (png)
  </code></pre>
  
  <p>I only know of two stable assumptions I can make. 1) there will be a 3-4 character file extension (obviously preceded by a period). 2) the frame number is always just before the file extension. Beyond that it is a free for all, which is where I get tripped up. Sometimes there are other numbers in the file name, and sometimes they have periods (or other characters) before/after them. So in essence I need to be able to capture the LAST instance of a series of numbers greater than 0 (hope that makes sense).</p>
  
  <p>I found that <code>(.{3,4})$</code> will match a file extension, while <code>([0-9]+)</code> will match any sequence of numbers. So the following gets me nearly there, I'm just missing everything before the sequence number as a group: <code>([0-9]+)\.(.{3,4})$</code></p>