Ruby: String#split on empty pattern or string

RDoc Documentation [ruby-doc.org]

“Funny” feature, actually only for wierdos:

If pattern is a Regexpstr is divided where the pattern matches. Whenever the pattern matches a zero-length string, str is split into individual characters. If pattern contains groups, the respective matches will be returned in the array as well.

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.