title: How to extract same parts of file name with different patterns?
body: <p>I have the following file name formats:</p>
  <pre><code>2020-01-05-ABC1111_001.jpg
  2020_02_06_B444444_MN_004.jpg
  2020_03_20_KUKU44223222-STAFF_005.jpg
  2020-04-03-LULU4444211-MN_018.jpg
  </code></pre>
  <p>Most (99%) of the files are of the following format:</p>
  <pre><code>2020_04_03_LULU4444211_018.jpg
  </code></pre>
  <p>And I just use <code>rsplit(&quot;_&quot;, 2)</code> and get what I need.</p>
  <p>Where the first part is date, second is and ID, MN or STAFF, page number.</p>
  <p>How to build a good regex or split function to somehow split it to date, id, and page?</p>
  <p>From all the above examples I would like to get:</p>
  <pre><code>{
  &quot;2020-01-05-ABC1111_001.jpg&quot;: {&quot;date&quot;: 2020-01-05, &quot;id&quot;: ABC1111, &quot;page_num&quot;: 1},
  &quot;2020_02_06_B444444_MN_004.jpg&quot;: {&quot;date&quot;: 2020_02_06, &quot;id&quot;: B444444, &quot;page_num&quot;: 4},
  &quot;2020_03_20_KUKU44223222-STAFF_005.jpg&quot;: {&quot;date&quot;: 2020_03_20, &quot;id&quot;: KUKU44223222, &quot;page_num&quot;: 5},
  &quot;2020-04-03-LULU4444211-MN_018.jpg&quot;: {&quot;date&quot;: 2020-04-03, &quot;id&quot;: LULU4444211, &quot;page_num&quot;: 18}
  }
  </code></pre>
  <p>I am have tried <code>rsplit</code>, I know there is an annotation option + Spacy NER model but maybe there is another way to do it more simply?</p>