On 10/31/06, Kirill Shutemov <k.shutemov / gmail.com> wrote:
> irb(main):001:0> "aabbcc".split(/bb/)
> => ["aa", "cc"]
> irb(main):002:0> "aabbcc".split(/(bb)/)
> => ["aa", "bb", "cc"]
> irb(main):003:0> "aabbcc".split(/bb(c)?/)
> => ["aa", "c", "c"]
>
> The last two result is unexpected for me. Can anybody explain it?

If there are any groups in the delimiter, they are output as well.
This is not documented in RDoc, only in the PickAxe book.

It's useful when you want to keep the delimiters.