Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Parsing CVS files



On Sun, Feb 03, 2019 at 05:19:08AM +0100, Sebastian Gniazdowski wrote:
> On Sat, 2 Feb 2019 at 21:27, Peter Stephenson
> > Also, if you want to keep empty fields, you'll need the final result
> > to use "${(@}this}".  Probably easiest to assign to an array as otherwise
> > the quotes will affect the substitution.
> 
> I've had to use "(@)" for every segment, i.e.:
> 
> % line='abc,"efg, hehe,yeah",c,,d'
> % print -rl "${(@)${(@)${(@)${(z)${${line// /\\ }//,/, }}%%,}//, /,}//\\ / }"
> abc
> "efg, hehe,yeah"
> c
> 
> d
> 
> And with a random "(@)" missing:
> % print -rl "${(@)${${(@)${(z)${${line// /\\ }//,/, }}%%,}//, /,}//\\ / }"
> abc "efg, hehe,yeah" c  d

Uff, looks complicated but should fix my problem.  Thanks!

Spaces and backslashes are no real problem beacause they can be
replaced with some unique character sequence before splitting.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt



Messages sorted by: Reverse Date, Date, Thread, Author