In between a string escaping comma

test = ‘Foo,Bar Baz’

expected output :

how can i achieve this

arr = test.split()

#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.

Not in this case. Splt has a default arg
split{} is equal to split(" ")

It is very simple to write negative code behind of string and run it

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