On Jul 13, 2004, at 9:03 PM, Bill Kelly wrote:

> Even with /\s+/ we're getting a leading empty field that
> the " " special case eliminates for us.
>
> I've never been sure how to write a regexp for split that
> does what " " does.  I keep thinking it'd need a variable-
> width negative lookbehind assertion... which I don't think
> even Perl's regex engine supports... Something like:
>
>   /(?<!^\s+)\s+/  ...uh....
>
> ...Maybe there's another way to do it... If anybody knows
> I'd like to learn...

as of now, this works:

irb(main):001:0> "  spaces  of  doom  ".split(nil)
=> ["spaces", "of", "doom"]

Why shouldn't nil be the only special case? If the $variable is set to 
nil, it uses this kind of split anyway.

And it's no more characters to type than " " ;)

Mark