[Chicago] Basic Regex Question
Massimo Di Pierro
mdipierro at cs.depaul.edu
Sat Feb 21 17:55:19 CET 2009
This should do it
album_regex = re.compile(r'^(?P<artist>.*)\s-\s(?P<album>.*?)\((?
P<label>.*)\)$')
On Feb 21, 2009, at 10:23 AM, Chris McAvoy wrote:
> Hi All,
>
> I have the following regex:
> album_regex = re.compile(r'(?P<artist>.*)\s-\s(?P<album>.*)\((?
> P<label>.*)\)')
>
> Which matches things like: John Coltrane - Interstellar Space
> (Impulse ASD 9277)
> artist: John Coltrane
> album: Interstellar Space
> label: Impulse ASD 9277
>
> very well, but has troubles on lines like:
>
> John Coltrane - Coltrane In Japan (Impulse (J) IMR 9036C)
> artist: John Coltrane
> album: Coltrane In Japan (Impulse
> label: J) IMR 9036C
>
> I get the feeling that there's a simple switch to say "get the first
> and last parens", but I'm having trouble with it, as I'm impatient,
> and not so hot at regex's.
>
> Help me ChiPy, you're my only hope.
>
> Chris
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
More information about the Chicago
mailing list