In between a string escaping comma

test = ‘Foo,Bar Baz’

expected output :
“Foo,Bar”,“Baz”

how can i achieve this

arr = test.split()
arr.to_s

#split takes an argument to specify the delimiter.

"Foo,Bar Baz".split(" ")
# => ["Foo,Bar", "Baz"]

You can also use regular expressions to match more complex delimiters.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs