Feature #5120
Updated by sawa (Tsuyoshi Sawada) over 4 years ago
I would call this a bug, but i am new to Ruby, so i report this as a feature request. Here are examples showing a surprising and inconsistent behavior of `String#split` String#split method: ```ruby "aa".split('a') # => [] "aab".split('a') # => ["", "", "b"] "aaa".split('aa') # => ["", "a"] "aaaa".split('aa') # => [] "aaaaa".split('aa') # => ["", "", "a"] "".split('') # => [] "a".split('') # => ["a"] ``` What is the definition of `split`? I *split*? In my opinion, there should be given a simple one that would suggest something like this: `str1.split(str2)` make it clear what to expect. For example: str1.split(str2) returns the a maximal array of non-empty substrings of `str1` that str1 which can be concatenated with copies of `str2` str2 to form `str1`. str1. Addition Additional precisions can be made to this definition to make clear what to expect as the result of `"baaab".split("aa")`. "baaab".split("aa"). Thanks for attention.