Here's another handy Perl regex which I am not sure how to translate to Python. I use it to avoid processing lines that contain funny chars... if ($string =~ /[^[:print:]]/) {next OUTER;} :)