How to test characters of a string
Christian Gollwitzer
auriocus at gmx.de
Thu Jun 9 08:23:07 EDT 2022
Am 09.06.22 um 07:50 schrieb Dave:
> Hi,
>
> I’ve found you also need to take care of multiple disk CD releases. These have a format of
>
> “1-01 Track Name”
> “2-02 Trackl Name"
>
> Meaning Disk 1 Track1, Disk 2, Track 2.
>
> Also A and B Sides (from Vinyl LPs)
>
> “A1-Track Name”
> “B2-Track Name”
>
> Side A, Track 1, etc.
>
Now you're getting into the complexity that is better handled by REs
than by individual character examination.
The first of your formats matches the RE
\d-\d{2}
(one digit, - two digits). Anchor that to check for a match at the
beginning.
The second one matches
(A|B)\d-
As long as one digit is enough. What is your goal, to extract these
numbers or to strip them? Regexes can do both relatively easily.
Christian
More information about the Python-list
mailing list