From: Lloyd Zusman Date: 2004-07-14T19:00:38+09:00 Subject: Re: String.split "Robert Klemme" writes: > "Cameron McBride" schrieb im Newsbeitrag > news:dcedf5e204071320562e0ad096@mail.gmail.com... >> > What possible benefit is there to typing split(" ") vs. split(/\s/)? >> > One saved character (but two shift key presses!)? >> >> they are not the same: >> >> irb(main):001:0> s = "this is\tfun \tno?" >> => ["this", "is", "fun", "no?"] >> irb(main):003:0> s.split(" ") >> => "this is\tfun \tno?" >> irb(main):002:0> s.split(/\s/) >> => ["this", "is", "fun", "", "no?"] > > I'd rather compare split(" ") to split(/\s+/), which is what I use when I > need this functionality. [ ... ] However, the two cases are not equivalent: irb(main):001:0> " spaces of doom ".split(/\s+/) => ["", "spaces", "of", "doom"] irb(main):002:0> " spaces of doom ".split(" ") => ["spaces", "of", "doom"] You'd have to compare split(" ") with strip.split(/\s+/). I'll do that later this morning, when I have more time, and I'll then post my results. -- Lloyd Zusman ljz@asfast.com God bless you.