From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24791 invoked by alias); 9 May 2012 15:06:40 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17066 Received: (qmail 15210 invoked from network); 9 May 2012 15:06:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Wed, 9 May 2012 15:38:48 +0100 From: Peter Stephenson To: reckoner CC: Zsh Users Subject: Re: how to use character range [] in substitution pattern :gs Message-ID: <20120509153848.3d756e82@pwslap01u.europe.root.pri> In-Reply-To: References: <4FAA78BD.3020602@gmail.com> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.101.10.18] X-Scanned-By: MailControl 7.7.0.1 (www.mailcontrol.com) on 10.71.1.142 On Wed, 9 May 2012 16:23:20 +0200 J=C3=A9r=C3=A9mie Roquet wrote: > 2012/5/9 reckoner : > > 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 synt= ax, > > so I'm pretty sure that I'm using the character range [] incorrectly > > somehow. >=20 > 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//[\(\)]/_} --=20 Peter Stephenson 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, Cambr= idge 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