Michael W. Ryder wrote: > As part of a method I am playing with while learning Ruby I need to be > able to determine which characters in a string are non-printable. What > is the "best" method for determining if a character is printable, such > as an "A", or unprintable, such as a tab? > While I could create a list of printable characters using ranges is this > the best way to do this? > The POSIX character classes are for exactly this: irb(main):001:0> "A \n B \t C".gsub(/[[:graph:]]/, '') => " \n \t " irb(main):002:0> "A \n B \t C".gsub(/[[:print:]]/, '') => "\n\t" -- Alex