[Coldstuff] spacing with explode()

Greg Hudson coldstuff@cold.org
07 Apr 2002 13:15:40 -0400


On Sun, 2002-04-07 at 12:21, Adam Cormany wrote:
> Shouldn't it be:
> ;"hi hi".explode(" ", 1);
> => ["hi", "", "hi"]
> 
> ;"hi  hi".explode(" ", 1);
> => ["hi", "", "", "hi"]

No.  A blank is when there are two separators with nothing between them,
not when there is one separator.

> I'm wanting to keep the blank lines in a string when
> exploded, but it keeps giving me the wrong number of
> spaces.

Just assume that there is one separator between each exploded field.