regexp strangeness

Dale Amon amon at vnl.com
Thu Apr 9 15:48:11 EDT 2009


This finds nothing:

import re
import string
card       = "abcdef"
DEC029     = re.compile("[^&0-9A-Z/ $*,.\-:#@'=\"[<(+\^!);\\\]%_>?]")
errs       = DEC029.findall(card.strip("\n\r"))
print errs

This works correctly:

import re
import string
card       = "abcdef"
DEC029     = re.compile("[^&0-9A-Z/ $*,.\-:#@'=\"[<(+\^!)\\;\]%_>?]")
errs       = DEC029.findall(card.strip("\n\r"))
print errs

They differ only in the positioning of the quoted backslash.

Just in case it is of interest to anyone.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20090409/ed06c1b1/attachment.sig>


More information about the Python-list mailing list