Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Splitting on unquoted equals
- X-seq: zsh-users 20180
- From: Jesper Nygårds <jesper.nygards@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Splitting on unquoted equals
- Date: Wed, 6 May 2015 09:25:46 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=7xjJ2m65ed7/r7Fgv50s+KEPP96kenzPpqzqIsBTbE8=; b=r0yVbl3O7ZXzSZzcsHpJYt4v2x652+nnm1w1MS0IC6IHbbVfr7ndJgx0C6vPHCTnMc Epsb4pQFilxKpoyqDsw1oUudKVNn6UuR6yUilBDVlHDiV2dVTqd8s0SkzoYdI5XU7SuR Ps2/Z/7qcSAQjEr85PUGTiD/VmlGI+LqYG0hYXnkFzTq2OKrGED71p//mmrSOpg1Sd1p 6RGe5jbgm98F185puqUEsre5FTpMDLHnUDNcCEJqfJgwUqiebvq48yIhawj5gRc58m5i jwM6m5nq0ovPV20wtzxYAl5eiVQTecaz028tn1FTzrZgepaJo3nQ8w4qjzv2imMq8g2U q7AA==
- In-reply-to: <150506000620.ZM19100@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CABZhJg8UohRUPtkbdS0MkdwzM4b2BiPv9XZD-zRkYWREjk+F5w@mail.gmail.com> <150506000620.ZM19100@torch.brasslantern.com>
Thank you. Your alternative approach works brilliantly for my problem.
On Wed, May 6, 2015 at 9:06 AM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
wrote:
> On May 6, 8:28am, Jesper Nygards wrote:
> }
> } Is there a way to say "split on '=' but not within quotes", similar to
> the
> } way (z) treats white space?
>
> Not really. (z) works because it "understands" shell syntax. You are
> asking for the shell to "understand" HTML syntax. It does not. You
> have two choices:
>
> (1) Write an actual HTML element parser, in shell script. (Probably
> easier to use Perl HTML::Parser or similar.)
>
> (2) Approach the problem differently. For example, if you first split
> on double-quotes and spaces and then strip off trailing equal signs:
>
> torch% print -l ${${=${(s'"')mystring}}%=}
> <element
> name
> myelement
> url
> http://site.com/path/config?myname=user
> >
>
> Curious aside - this doesn't work:
>
> torch% print -l ${(s:\":)string}
> <element name="myelement" url="http://site.com/path/config?myname=user">
>
> But you can't use an un-escaped quote mark there either:
>
> torch% print -l ${(s:":)string}
> braceparam dquote>
>
> --
> Barton E. Schaefer
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author