Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: regular expressions and setting variables?
- X-seq: zsh-users 18895
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: "William G. Scott" <wgscott@xxxxxxxx>
- Subject: Re: regular expressions and setting variables?
- Date: Tue, 10 Jun 2014 04:45:27 -0400
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d201312; h=In-Reply-To:Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=BD6p8af85PFNARm0J0282ioKAoZNe+2fCcEZgRqCoiM=; b=Ai3UuY62nourPt4YBYl9DTG2zDFh2IlwBwuw0SBknaFB3OECHOrybkQ2GWwEYq0WyUL8fdeYFESqAJgtc3n37zme4o4PguM30D2sr6sF+PwXWgOuDp/zJb2OkX1+1KP7hrMe9f0iufVC/PUMVPmGobXcs/VsPfd+ExCZegJyvk99/C+WbavzGPpY0U5P9zrv9iEXnQL3uaS+Pfn+;
- In-reply-to: <157E3510-D220-4C1C-A452-93DE96DA4363@chemistry.ucsc.edu>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: "William G. Scott" <wgscott@xxxxxxxx>, zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Openpgp: url=https://www.security.spodhuis.org/PGP/keys/0x3903637F.asc
- References: <157E3510-D220-4C1C-A452-93DE96DA4363@chemistry.ucsc.edu>
On 2014-06-09 at 22:04 -0700, William G. Scott wrote:
> This works:
>
> JUNK=R.E.M.
> print ${JUNK}| perl -p -e 's|\.$|_|g’
>
> It returns
> R.E.M_
>
>
> But if I try to do this:
>
> print ${JUNK/\.$/_}
>
> it returns
> R.E.M.
>
> I assume I am not using the correct regexp. What do I need to do to get this working?
${name/pattern/repl} does not use regular expressions, it uses shell
patterns.
Described in zshexpn(1) under "PARAMETER EXPANSION".
% echo ${JUNK/%./_}
R.E.M_
-Phil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author