Arbiter
Arbiter

Reputation: 47

Splitting a string into multiple strings after a specified character in Ruby

I am trying to create a script that takes in a string with an unknown number of parts that are separated by ';'.

"blah blah one; blah blah two"

I tried to use the (?: re) example from rubydocs but had no luck with it. Can someone show me the best way to do this?

Upvotes: 0

Views: 879

Answers (1)

kurumi
kurumi

Reputation: 25599

you can just use the split method

a='blah blah blah;blah foo blah'.split(";")

the parts will be store in index from 0 to 1 (in the above example )

Upvotes: 2

Related Questions