Just got bitten by some functionality of split w/ grouped patterns:
(in ruby 1.8.6…)
“foo bar baz”.split(/bar/)
=> ["foo “, " baz”]
“foo bar baz”.split(/(bar)/)
=> ["foo “, “bar”, " baz”]
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
array as well. "
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?
Anyhoo, if anyone else gets weird behavior for string split including
pattern, or with groups in the pattern, maybe you’ll remember this or
google will tell you about this.