Hi all,
Rather difficult problem I have I think.
I am processing large amounts of data and at the end of processing I
wish to remove all unprintable characters from the resulting file.
At the moment I have to load the file up into a good text application
and run a find and replace find the following phrase
find: [^[:print:]]
replace:
I then select regular expression of the find and replace and it goes off
and looks for all unprintable characters and replaced them with nothing.
Ideally I would like to do this in Ruby, something like
data.gsub([^[:print:]], "")
Obviously it is far more complex that this and I am looking for input.
Thanks in advance
···
--
Posted via http://www.ruby-forum.com/.
is it?
this seems to work without problem for me:
data = File.read("some/crazy/mp3")
data.gsub(/[^[:print:]]/, "")
Ruby 1.9 needs force_encoding("binary"), but basically the same deal.
I assume I'm missing something obvious :\
···
On Aug 14, 9:46 am, Stuart Clarke <stuart.clarke1...@gmail.com> wrote:
Hi all,
Rather difficult problem I have I think.
I am processing large amounts of data and at the end of processing I
wish to remove all unprintable characters from the resulting file.
At the moment I have to load the file up into a good text application
and run a find and replace find the following phrase
find: [^[:print:]]
replace:
I then select regular expression of the find and replace and it goes off
and looks for all unprintable characters and replaced them with nothing.
Ideally I would like to do this in Ruby, something like
data.gsub([^[:print:]], "")
Obviously it is far more complex that this and I am looking for input.
Thanks in advance
--
Posted viahttp://www.ruby-forum.com/.