[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Natural order sort

Dave Thomas

9/15/2003 5:52:00 PM


On Monday, September 15, 2003, at 12:07 PM, Alan Davies wrote:
> Interesting. I always assumed split filtered out the matching
> sections, but it appears that you can make them appear in the
> resulting array by putting brackets round the relevant bit in the
> regexp.
>
> This isn't mentioned in the Pragmatic Programmers book.
>

It is now :)


1 Answer

Mark J. Reed

9/15/2003 6:02:00 PM

0

On Monday, September 15, 2003, at 12:07 PM, Alan Davies wrote:
> Interesting. I always assumed split filtered out the matching
> sections, but it appears that you can make them appear in the
> resulting array by putting brackets round the relevant bit in the
> regexp.

Yup. That''s because it was modeled after the split function in
Perl, which behaves exactly the same way.

Given the relative paucity[1] of Ruby documentation, familiarity with
Perl can be a good way to set your behavioral expectations. Of course,
if it''s something you can test (as opposed to a feature which might or
might not occur to you at all), that''s the best way to determine the
behavior.

-Mark

[1] I did say "relative". There''s just a heckuva lot more info out there
about Perl. The Ruby situation is steadily improving, however, and the
Pickaxe book is a wondrous thing. :)