Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Splitting on unquoted equals
- X-seq: zsh-users 20178
- From: Jesper Nygårds <jesper.nygards@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Splitting on unquoted equals
- Date: Wed, 6 May 2015 08:28:36 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=bE23trowb8KGB1a8/tNIzOImDyW99l7dOpUNXtVK6wA=; b=AyZFuyOH2xcXZNMrRM5TgmgaWViqVJXY3A62499xs3w7KDqrNn/XbEQb/VVDRtDiAT f+svOAYkYHQAyAwZm80eatr2T4RASxMht4qPXpfPjIn+o9tzPquDHO63V+xM04kBP1Vt C3FXnubIa8tWHxE8RrFWzIaGUgQb5c0kO0z1gCkIsc78Ywf3ygttqbTsY+hNUCT64vbm OtcOs7yWBRfrLoKZurFmHm8vYdRZVG+hWYzdlo56FXdiZCSuXSVZ20l3NyJHWrYMm5Zm 3bBsETOG+a5PgeJ7mNSlS0gTvYEBlazlVNtkG/RtsMZFnQdUIE4qppkpAjAgMfuLiLD+ qsSw==
- 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
I am trying to extract url:s from an XML document, where I have fragments
resembling the following:
<element name="myelement" url="http://site.com/path/config?myname=user">
Say I assign the above to a variable:
% mystring="<element name=\"myelement\" url=\"
http://site.com/path/config?myname=user\">"
Is there a way to split this string on '=' but not within the quotes? If I
only do this:
% print -l ${(s:=:)mystring}
<element name
"myelement" url
"http://site.com/path/config?myname
user">
The url has of course been split on '=' as well, which is not what I want.
Is there a way to say "split on '=' but not within quotes", similar to the
way (z) treats white space?
% myspaces="this is \"three arguments\""
% print -l ${(z)myspaces}
this
is
"three arguments"
Here the space is preserved within quotes. Is there a way to achieve
something similar but with '='?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author