Regular Expressions and Python 1.5.2

Alexandre Fayolle alf at
Thu Mar 15 11:01:08 CET 2001

Alexandre Fayolle <alf at> 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
Narval is the first software agent available as free software (GPL).
LOGILAB, Paris (France).

More information about the Python-list mailing list