Regular Expressions and Python 1.5.2
Matt Dunford
kno at jtan.com
Thu Mar 15 05:09:24 EST 2001
* Alexandre Fayolle <alf at leo.logilab.fr>:
> 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)
> '*&*'
Your regex's look fine to me. Remember that an '-' indicates a range
of characters. '[ -/]' will match exactly that: <space> through
<forward slash>. An '&' is between those two. Check out this ascii
chart.
http://www.jimprice.com/ascii-0-127.gif
--
More information about the Python-list
mailing list