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

Splitting on unquoted equals



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