Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: parameter expansion, substitution
- X-seq: zsh-workers 30336
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: "S. Cowles" <scowles@xxxxxxxx>
- Subject: Re: parameter expansion, substitution
- Date: Fri, 9 Mar 2012 23:25:25 +0100
- Cc: zsh-workers@xxxxxxx
- 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 :cc:content-type; bh=aQZ2cEIy0ji4Xn5nPkTY9XLSJkmX8ZjSgVFFGKqjqvA=; b=hBErvkKVR4ENE4ZSoubHe/dJOhs4MBeZigDSMlXwnbii3XkilbGnTIc6qINV07/FrZ J7sQdrvGwIjPf8aPY6XcFPe0lLtwtaRRY/KRubQJ0npZlXpo4Xtzllc/x6dHcEpxFUx4 TN2RvwVtrWepXLgrloMoUoSlU3gaDgE5tXavTOJvswMAIOl4VqpavAZEDMj+VQLEDKP2 Yg3hFEFWChUQI8Y+ttapr5kswR/LhNpYZ9YJHOpUDWPjGee9lD8KdQHzt0ZtqLxXoX7N 7e2bWc+5zBNdo0PRiEXfeRMrKQZ1hN6fVPPfKr709bc60zy5SsOiMWtl+sAnVbOPX7BS 60rQ==
- In-reply-to: <alpine.LN8.2.00.1203091332580.1456@ckhb06.ckhb.org>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <alpine.LN8.2.00.1203091332580.1456@ckhb06.ckhb.org>
On 9 March 2012 23:03, S. Cowles <scowles@xxxxxxxx> wrote:
> i am not getting expected results in the following code snippet:
> b="abc" ; b=${b/#abc%/d} ; echo ${b}
> i expect the value of b to be changed to "d"; however, it remains "abc".
>
> the following snippet does give the expected result:
> b="abc" ; b=${b/#abc/d} ; echo ${b}
>
> for this session, the following shell options are set: interactive monitor
> shinstdin zle. the version of the shell being used is 4.3.17-dev-0,
> patchlevel 1.5604.
>
> in my use case, i need to specify a pattern match at the end of the
> parameter. have i misunderstood the syntax of the '%' end-of-string
> operator? or is this problem something else?
>
> thanks for any help.
It's possibly a bit counterintuitive, but both # and % go at the start
of the string, so you want
b=${b/#%abc/d}
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author