Regular Expressions and Python 1.5.2

Alexandre Fayolle alf at leo.logilab.fr
Thu Mar 15 05:01:08 EST 2001


Alexandre Fayolle <alf at leo.logilab.fr> wrote:
> Is this a known bug in the module re of python 1.5.2, or am I missing 
> something obvious?

>>>> import re
>>>> t = "m&n"
>>>> re.sub('[^/_ -]','*',t)
> '***'
>>>> re.sub('[^_ -/]','*',t)
> '*&*'

[hits himself on the head with a dead fish]
OK, I was bit tired when I wrote the code. I had forgotten that '-' has 
a special meaning. Obviously, '&' lies somewhere between '_' and '/'.

Sorry for the noise.

Alexandre Fayolle
-- 
http://www.logilab.com 
Narval is the first software agent available as free software (GPL).
LOGILAB, Paris (France).



More information about the Python-list mailing list