I am working with files that can have either a DOS
or a Unix format, then ending in either '\n' or '\r\n'.
Can chomp be configured to chomp '\n' or '\r\n' from
a string without having to modify the string class?
Right now I get:
irb(main):001:0> s="test\r\n"
"test\r\n"
irb(main):002:0> s.chomp
"test\r"
I could obtain the desired results if I did
irb(main):003:0> s.chomp("\r\n")
"test"
but this fails for lines ending in only '\n'
irb(main):004:0> t="test\n"
"test\n"
irb(main):005:0> t.chomp("\r\n")
"test\n"
I would think there would be a better way than my following
solution:
irb(main):010:0> t.chomp("\r\n").chomp
"test"
irb(main):012:0> s.chomp("\r\n").chomp
"test"
Thanks
=========================================================
Jim Freeze
jim / freeze.org
---------------------------------------------------------
No comment at this time.
http://www.freeze.org
=========================================================