------_=_NextPart_001_01C5C7E3.D3A52FE2
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
I'm guessing the reason it worked after splitting and not before is due =
to you not using a multiline regexp.
I believe in 1.8 regexp was changed to automatically be multi-line...if =
I recall correctly.
So it would have to be like gsub(/\n/m,"")
-Justin
-----Original Message-----
From: Kev Jackson [mailto:
[email protected]]
Sent: Sun 10/2/2005 8:30 PM
To: ruby-talk ML
Subject: Re: ruby gsub! problem
=20
The typical Ruby idiom for this is:
File.foreach(filename) do |line|
line.chomp!
# ... processing code goes here ...
end
I didn't ry it to be honest, the real problem was that the data (when=20
exported by another tool), has (\n) line endings at arbitrary places (ie =
3 in a typical 'line' of data). So I really wanted to strip them out=20
before resplitting on the real line delimiter ';'. I actually worked it =
out, I was trying filename.to_s.gsub!(/\n/, ''), but although ruby won't =
complain about this, it won't operate on it, if instead I spli on my=20
delimiter ';' and then do a line.gsub!(/\n/,'') everything works fine
Thanks for the help
Is the idiom above more for processing multiple files (for each file,=20
for each line do some processing close) kind of thing?
Kev
------_=_NextPart_001_01C5C7E3.D3A52FE2--