From: William Djaja Tjokroaminata Date: 2002-10-03T06:03:55+09:00 Subject: Re: Regexp: Stripping out all except ASCII? Hi Mark, Depending on what you mean with "valid ASCII", probably using a lower level representation is more appropriate than using a regular expression. Just an example: ARGF.each_byte do |byte| if byte < 128 print byte.chr end end I guess, you can just change the criterion (byte < 128) to suit your need. You may even be able to transform the above code to a one-liner. Regards, Bill ======================================================================== Mark Probert wrote: > Hi. > A simple one, again. How do I strip out all chars > except valid ASCII from a file? > while line = gets() > line.sub(/[^\w]/, " ") > puts line > end > leaves stuff, such as ESC sequences. Any ideas? > Is there a one-liner for this?