How can I get the array
["hello", "world", "123"]
from the string
"hello\r\nworld\r\n123"
Thanks!
Dominique
irb(main):001:0> "hello\r\nworld\r\n123".split
=> ["hello", "world", "123"]
irb(main):011:0> "hello\r\nworld\r\n123".split(/\s+/)
=> ["hello", "world", "123"]
irb(main):012:0> "hello\r\nworld\r\n123".scan(/\S+/)
=> ["hello", "world", "123"]
irb(main):004:0> "hello\r\nworld\r\n123".to_a.map{|x|x.chomp}
=> ["hello", "world", "123"]
irb(main):009:0> "hello\r\nworld\r\n123".inject([]){|a,b| a << b.chomp}
=> ["hello", "world", "123"]