From: Mark Probert Date: 2002-10-03T06:12:50+09:00 Subject: Re: Regexp: Stripping out all except ASCII? At 05:43 AM 10/3/2002 +0900, Mike wrote: >In article <5.1.0.14.2.20021002161707.030aecd8@zcard04k.ca.nortel.com>, >Mark Probert wrote: > > > > Hi. > > > > A simple one, again. How do I strip out all chars > > except valid ASCII from a file? > >What do you mean by "valid ASCII" here? Are you really after printable >characters < chr(128)? e.g. > > line.gsub!(/[^ -~]/, ' ') My apologies, I wasn't clear. The file is plain text that has curses detritus all the way through it. A sample is: [23DOPC Save and Restore [0m[m [23DOPC Shutdown [19DOPC Date [0;7m[m [23DPort Configuration [0;7m[m [23DIP Routing Admin [C Unix Shell [10DOPC PM Coll. Filter [19DTL1 Configuration [20DLog Archive Your suggestion is excellent at getting rid of the \C-? characters. Any ideas on the escape strings? -mark.