zsh-users
 help / color / mirror / code / Atom feed
From: "Jesper Nygårds" <jesper.nygards@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Splitting on unquoted equals
Date: Wed, 6 May 2015 09:25:46 +0200	[thread overview]
Message-ID: <CABZhJg_S9FYZ=WpyFvC0morcR+rKh3zDr9CQYuJ_aS17rNR8sQ@mail.gmail.com> (raw)
In-Reply-To: <150506000620.ZM19100@torch.brasslantern.com>

[-- Attachment #1: Type: text/plain, Size: 1175 bytes --]

Thank you. Your alternative approach works brilliantly for my problem.


On Wed, May 6, 2015 at 9:06 AM, Bart Schaefer <schaefer@brasslantern.com>
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
>

      reply	other threads:[~2015-05-06  7:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-06  6:28 Jesper Nygårds
2015-05-06  7:06 ` Bart Schaefer
2015-05-06  7:25   ` Jesper Nygårds [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABZhJg_S9FYZ=WpyFvC0morcR+rKh3zDr9CQYuJ_aS17rNR8sQ@mail.gmail.com' \
    --to=jesper.nygards@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).