split() into individual chars (evening CVS)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

split() into individual chars (evening CVS)

Mikołaj Machowski
Hello,

Why previous method of splitting string into individual characters was
changed?
split('string', '') was quite nice and worked
advertised
split('string', '\zs')
returns
['s', '', 't', '', 'r', '', 'i', '', 'n', '', 'g']
Which is all but expected...

--
LaTeX + Vim = http://vim-latex.sourceforge.net/
Vim-list(s) Users Map: (last change 15 May)
 http://skawina.eu.org/mikolaj/vimlist
CLEWN - http://clewn.sf.net
Reply | Threaded
Open this post in threaded view
|

Re: split() into individual chars (evening CVS)

Bram Moolenaar

Mikolaj Machowski wrote:

> Why previous method of splitting string into individual characters was
> changed?
> split('string', '') was quite nice and worked
> advertised
> split('string', '\zs')
> returns
> ['s', '', 't', '', 'r', '', 'i', '', 'n', '', 'g']
> Which is all but expected...

That's a side effect of keeping empty items when splitting "aaa::bbb"
into ['aaa', '', 'bbb'].

Obviously you don't want empty items when the pattern match is empty.
I'll see how that can be done without making it complicated.

--
BEDEVERE:        Why do you think she is a witch?
SECOND VILLAGER: She turned me into a newt.
BEDEVERE:        A newt?
SECOND VILLAGER: (After looking at himself for some time) I got better.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: split() into individual chars (evening CVS)

Mikołaj Machowski
Dnia ?roda 25 maj 2005 11:42, Bram Moolenaar napisa?:

> Mikolaj Machowski wrote:
> > Why previous method of splitting string into individual characters was
> > changed?
> > split('string', '') was quite nice and worked
> > advertised
> > split('string', '\zs')
> > returns
> > ['s', '', 't', '', 'r', '', 'i', '', 'n', '', 'g']
> > Which is all but expected...
>
> That's a side effect of keeping empty items when splitting "aaa::bbb"
> into ['aaa', '', 'bbb'].
>
> Obviously you don't want empty items when the pattern match is empty.
> I'll see how that can be done without making it complicated.

Ha. Try
split('string', '.\zs')
:D

Just one, small correction in docs.

m.