[Chicago] Basic Regex Question

Chris McAvoy chris.mcavoy at gmail.com
Sat Feb 21 17:23:50 CET 2009

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.


More information about the Chicago mailing list