Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: how to use character range [] in substitution pattern :gs
- X-seq: zsh-users 17066
- From: Peter Stephenson <Peter.Stephenson@xxxxxxx>
- To: reckoner <reckoner@xxxxxxxxx>
- Subject: Re: how to use character range [] in substitution pattern :gs
- Date: Wed, 9 May 2012 15:38:48 +0100
- Cc: Zsh Users <zsh-users@xxxxxxx>
- In-reply-to: <CAFOazAPy7N_YGSoSekMcqDM_bbJjDj51ObT_Er9Ue=Jqj-KPEg@mail.gmail.com>
- 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
- Organization: Cambridge Silicon Radio
- References: <4FAA78BD.3020602@gmail.com> <CAFOazAPy7N_YGSoSekMcqDM_bbJjDj51ObT_Er9Ue=Jqj-KPEg@mail.gmail.com>
On Wed, 9 May 2012 16:23:20 +0200
Jérémie Roquet <arkanosis@xxxxxxxxx> wrote:
> 2012/5/9 reckoner <reckoner@xxxxxxxxx>:
> > I'm trying to use the the [] character range to substitute for embedded
> > parenthesis as in the following:
> >
> > % echo ${x:gs/[()]/_/}
> >
> > But This isn't working for some reason. It's not complaining about syntax,
> > so I'm pretty sure that I'm using the character range [] incorrectly
> > somehow.
>
> By default, the left side of a substitution is a string, not a
> pattern. You have to setopt HIST_SUBST_PATTERN to use patterns
> instead.
Probably better to use the syntax that already handles this:
${x//[\(\)]/_}
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
Messages sorted by:
Reverse Date,
Date,
Thread,
Author