From: Rob Biedenharn Date: 2009-02-11T05:46:36+09:00 Subject: Re: String#split "feature" On Feb 10, 2009, at 3:38 PM, 7stud -- wrote: > Gary Yngve wrote: >> >> The 1.8 docs are silent on this, but the 1.9 docs at least say >> "If pattern contains groups, the respective matches will be >> returned in >> the >> array as well. " >> > > pickaxe2 p.619: > ===== > split > ... > ... > If pattern includes groups, these groups will be included in the > returned values. > ... > ===== Interestingly, this feature is described in String#scan, but the ri docs for my Apple-provided ruby do not have the sentence for String#split. $ ruby -v ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] -Rob >> This "feature" surprised the heck out of me.. Anyone know if this >> functionality is intentional (from the enduser standpoint), or >> rather a >> byproduct of implementation details? >> > > It can be a really handy feature. python's regex split() function > works > the same way. > > >> Anyhoo, if anyone else gets weird behavior for string split including >> the >> pattern, or with groups in the pattern, maybe you'll remember this or >> maybe >> google will tell you about this. >> >> Thanks, >> -Gary > Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com