[Tutor] Removing control characters

Dinesh B Vadhia dineshbvadhia at hotmail.com
Thu Feb 19 16:14:59 CET 2009


I want a regex to remove control characters (< chr(32) and > chr(126)) from strings ie.

line = re.sub(r"[^a-z0-9-';.]", " ", line)   # replace all chars NOT A-Z, a-z, 0-9, [-';.] with " " 

1.  What is the best way to include all the required chars rather than list them all within the r"" ?
2.  How do you handle the inclusion of the quotation mark " ?

Cheers

Dinesh

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090219/87a8c782/attachment.htm>


More information about the Tutor mailing list