I need to do a .gsub or .split or the equivalent to locate
carriage-return
characters  Hex 0d . How can I do this in ruby? Thanks. Bill W.
On Thu, Apr 17, 2008 at 4:16 PM, Bill W. [email protected] wrote:
I need to do a .gsub or .split or the equivalent to locate carriage-return
characters Hex 0d . How can I do this in ruby? Thanks. Bill W.
irb → puts “hello\x0d”.gsub(/\x0d/, ‘!’)
hello!
Regards,
Sean
From: Bill W. [mailto:[email protected]]
I need to do a .gsub or .split or the equivalent to locate
carriage-return characters Hex 0d .
CR is represented as “\r”
0x0d.chr
#=> “\r”
so,
“test\rx”.gsub(/\r/){“[]”}
#=> “test[]x”
“test\rx asdfa\rasdf”.split(/\r/)
#=> [“test”, “x asdfa”, “asdf”]