Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -2,13 +2,7 @@ text = 'a!===b=!=c'
separators = ['==', '!=', '=']
def multisplit_simple(text, separators)
sep_regex = Regexp.new(separators.collect {|sep| Regexp.escape(sep)}.join('|'))
text.split(sep_regex)
text.split(Regexp.union(separators))
end
p multisplit_simple(text, separators)
["a", "", "b", "", "c"]
=> nil
p multisplit_simple(text, ['=', '!=', '=='])
["a", "", "", "b", "", "c"]
=> nil
p multisplit_simple(text, separators) # => ["a", "", "b", "", "c"]

View file

@ -1,5 +1,5 @@
def multisplit(text, separators)
sep_regex = Regexp.new(separators.collect {|sep| Regexp.escape(sep)}.join('|'))
sep_regex = Regexp.union(separators)
separator_info = []
pieces = []
i = prev = 0