Note that there are some explanatory texts on larger screens.

plurals
  1. PODetect and extract changing numbers in list of strings
    primarykey
    data
    text
    <p>Let's say I have a list of of audio file names (it could be any list of strings with continuing numbers in it) that have different naming schemes but all of them contain the track number in their file name.</p> <p>I want to extract the changing numbers.</p> <p><strong>Example 1</strong></p> <pre><code>Fooband 41 - Live - 1. Foo Title ... Fooband 41 - Live - 11. Another Foo Title </code></pre> <p><strong>Desired result</strong></p> <p>A list of numbers: <code>1,2,3,...,11</code></p> <p><strong>Example 2</strong></p> <pre><code>02. Barband - Foo Title with a 4 in it 05. Barband - Another Foo Title 03. Barband - Bar Title ... 17. Barband - Yet another Foo Title </code></pre> <p><strong>Desired result</strong></p> <p>A list of numbers: <code>2,5,3,...,17</code></p> <p>Since the position of the index number is not fixed, I (think) I cannot use regular expressions there.</p> <p><strong>What I have</strong></p> <ol> <li>Find a common prefix and suffix of the strings and chop that off</li> <li>See if there's a number on the left / right side of the string</li> <li>Use that number for getting the indices</li> </ol> <p>But there's a problem: If I find a common prefix for <strong>Example 1</strong>, the common prefix would be <code>Fooband 41 - Live - 1</code>, so <code>1</code> would be lost (likewise for a naming scheme like <code>Song X - 10, Song X - 11, ...)</code>.</p> <h2>Question</h2> <p><strong>What's a good way to detect and extract the changing number (on a similar position) in a list of strings?</strong></p> <p>I'm using Python (not that it matters for this problem)</p> <p>A bonus would be if I could detect Roman numbers as well, but I suspect that'd be much more difficult.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload