# use this to extract only printable chars from a string # class String def printable gsub(%r/[^[:print:]]/, '') end end p text_and_binary.printable