Checking strings for "bad" characters
hst at empolis.co.uk
Tue Aug 27 15:52:02 CEST 2002
I've got some very long Unicode strings which I wish to test for the presence of ASCII characters 0-8 and 14-31. My first thought was to use regular expressions, e.g.:
r = re.compile(u'[%s%s]' % (''.join([unichr(x) for x in range(0, 9)]) , ''.join([unichr(x) for x in range(14, 32)])))
amatch = r.search(r)
print "Bad characters"
but is there a better or faster method.
This message has been checked for all known viruses by the MessageLabs Virus Scanning Service.
More information about the Python-list