[Chicago] Basic Regex Question

Chris McAvoy chris.mcavoy at gmail.com
Sat Feb 21 17:58:20 CET 2009


Massimo is the winner!

Thanks

On Sat, Feb 21, 2009 at 10:55 AM, Massimo Di Pierro
<mdipierro at cs.depaul.edu> wrote:
> 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
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>


More information about the Chicago mailing list