Reputation: 1452
I have a long string, consisting of multiple sentences, of various length, divided by a "-
".
I want to iterate over the string and extract everything between the -
's, preferably to an array.
From another thread I found something that gets me pretty close, but not all the way:
longString.scan( /-([^-]*)-/)
Needless to say, I am new to Ruby, and especially to RegEx.
Upvotes: 2
Views: 397
Reputation: 96914
What's wrong with using String#split
?
longString.split('-')
Upvotes: 5