ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Re: String#split: unxepected result
by Jan Svitok other posts by this author
Oct 31 2006 2:09AM messages near this date
String#split: unxepected result | Re: String#split: unxepected result
On 10/31/06, Kirill Shutemov <k.shutemov@[...].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.
Thread:
Kirill Shutemov
Jan Svitok
Vincent Fourmond
Robert Klemme

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved