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 <probertm / nortelnetworks.com> 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?