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

Re: Per line ${..//..}



DervishD wrote:
>     I have a parameter containing a bunch of lines, and I have to get
> rid of comments (that is "$line" == (#s)[" $'\t'"]#\#*(#e)) and empty
> lines (that is "$line" == (#s)[" $'\t'"]#(#e)). I've tried using the
> ${..//..} syntax for doing substitutions in parameters, but with no
> success because I don't know how to properly mark the beginning and
> end of a line.

You can do something like:

% lines=(foo "# comment" bar "    ")
% print -l $lines
foo
# comment
bar

% print -l ${lines:#[[:space:]]#(\#*|)}
foo
bar

pws



This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com



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