RosettaCodeData/Task/Multisplit/Ruby/multisplit-1.rb

9 lines
203 B
Ruby
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
text = 'a!===b=!=c'
separators = ['==', '!=', '=']
def multisplit_simple(text, separators)
2015-02-20 00:35:01 -05:00
text.split(Regexp.union(separators))
2013-04-10 21:29:02 -07:00
end
2015-02-20 00:35:01 -05:00
p multisplit_simple(text, separators) # => ["a", "", "b", "", "c"]