Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -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"]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue