C's isprint() concept?

Jeff Pinyan jeffp at crusoe.net
Sun Aug 15 23:28:53 CEST 1999

>   $string =~ tr/\x00-\x1f\x80-\xff//d;

Perhaps, more readably:

  $string =~ tr/ -~//cd;

  the /c means complement (take the opposite of) the list
  the /d means delete those characters without a replacement
  the list is ' ' through '~', which is the class of printables

jeff pinyan    japhy at pobox.com  japhy+perl at pobox.com  japhy+crap at pobox.com
japhy's little hole in the (fire) wall:       http://www.pobox.com/~japhy/
japhy's perl supposit^Wrepository:       http://www.pobox.com/~japhy/perl/
The "CRAP" Project:                 http://www.pobox.com/~japhy/perl/crap/
CPAN ID: PINYAN           http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/

More information about the Python-list mailing list