From: Mikael Magnusson <mikachu@gmail.com>
To: "S. Cowles" <scowles@ckhb.org>
Cc: zsh-workers@zsh.org
Subject: Re: parameter expansion, substitution
Date: Fri, 9 Mar 2012 23:25:25 +0100 [thread overview]
Message-ID: <CAHYJk3R6P90wpqgKgxyuAp15RrR=RTxTL1XKBGz-WJF9+SBtng@mail.gmail.com> (raw)
In-Reply-To: <alpine.LN8.2.00.1203091332580.1456@ckhb06.ckhb.org>
On 9 March 2012 23:03, S. Cowles <scowles@ckhb.org> 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
next prev parent reply other threads:[~2012-03-09 22:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-09 22:03 S. Cowles
2012-03-09 22:25 ` Mikael Magnusson [this message]
2012-03-09 22:48 ` S. Cowles
2012-03-09 22:27 ` Bart Schaefer
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='CAHYJk3R6P90wpqgKgxyuAp15RrR=RTxTL1XKBGz-WJF9+SBtng@mail.gmail.com' \
--to=mikachu@gmail.com \
--cc=scowles@ckhb.org \
--cc=zsh-workers@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).