* how to use character range [] in substitution pattern :gs @ 2012-05-09 14:01 reckoner 2012-05-09 14:23 ` Jérémie Roquet 0 siblings, 1 reply; 7+ messages in thread From: reckoner @ 2012-05-09 14:01 UTC (permalink / raw) To: Zsh Users 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. Any help appreciated. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to use character range [] in substitution pattern :gs 2012-05-09 14:01 how to use character range [] in substitution pattern :gs reckoner @ 2012-05-09 14:23 ` Jérémie Roquet 2012-05-09 14:38 ` Peter Stephenson 0 siblings, 1 reply; 7+ messages in thread From: Jérémie Roquet @ 2012-05-09 14:23 UTC (permalink / raw) To: reckoner; +Cc: Zsh Users Hi, 2012/5/9 reckoner <reckoner@gmail.com>: > 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. Best regards, -- Jérémie ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to use character range [] in substitution pattern :gs 2012-05-09 14:23 ` Jérémie Roquet @ 2012-05-09 14:38 ` Peter Stephenson 2012-05-09 16:00 ` reckoner 0 siblings, 1 reply; 7+ messages in thread From: Peter Stephenson @ 2012-05-09 14:38 UTC (permalink / raw) To: reckoner; +Cc: Zsh Users On Wed, 9 May 2012 16:23:20 +0200 Jérémie Roquet <arkanosis@gmail.com> wrote: > 2012/5/9 reckoner <reckoner@gmail.com>: > > 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@csr.com> 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to use character range [] in substitution pattern :gs 2012-05-09 14:38 ` Peter Stephenson @ 2012-05-09 16:00 ` reckoner 2012-05-09 16:34 ` Peter Stephenson 0 siblings, 1 reply; 7+ messages in thread From: reckoner @ 2012-05-09 16:00 UTC (permalink / raw) To: Peter Stephenson; +Cc: Zsh Users On 5/9/2012 7:38 AM, Peter Stephenson wrote: > On Wed, 9 May 2012 16:23:20 +0200 > Jérémie Roquet<arkanosis@gmail.com> wrote: >> 2012/5/9 reckoner<reckoner@gmail.com>: >>> 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//[\(\)]/_} > This last one doesn't work for me with or without the HIST_SUBST_PATTERN. Thanks! ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to use character range [] in substitution pattern :gs 2012-05-09 16:00 ` reckoner @ 2012-05-09 16:34 ` Peter Stephenson 2012-05-09 17:12 ` reckoner 0 siblings, 1 reply; 7+ messages in thread From: Peter Stephenson @ 2012-05-09 16:34 UTC (permalink / raw) To: reckoner; +Cc: Zsh Users On Wed, 9 May 2012 09:00:43 -0700 reckoner <reckoner@gmail.com> wrote: > > ${x//[\(\)]/_} > > This last one doesn't work for me with or without the HIST_SUBST_PATTERN. Hmm... there's not a lot to go wrong unless your version of zsh is *very* old. % zsh -f % x="foo(bar())rod" % print ${x//[\(\)]/_} foo_bar___rod -- Peter Stephenson <pws@csr.com> 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to use character range [] in substitution pattern :gs 2012-05-09 16:34 ` Peter Stephenson @ 2012-05-09 17:12 ` reckoner 2012-05-09 17:25 ` Re[2]: " Vadim Zeitlin 0 siblings, 1 reply; 7+ messages in thread From: reckoner @ 2012-05-09 17:12 UTC (permalink / raw) To: Peter Stephenson; +Cc: Zsh Users On Wednesday, May 09, 2012 9:34:45 AM, Peter Stephenson wrote: > On Wed, 9 May 2012 09:00:43 -0700 > reckoner<reckoner@gmail.com> wrote: >>> ${x//[\(\)]/_} >> >> This last one doesn't work for me with or without the HIST_SUBST_PATTERN. > > Hmm... there's not a lot to go wrong unless your version of zsh is > *very* old. > > % zsh -f > % x="foo(bar())rod" > % print ${x//[\(\)]/_} > foo_bar___rod > here's my version: zsh 4.3.11 (i686-pc-cygwin) Thanks! ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re[2]: how to use character range [] in substitution pattern :gs 2012-05-09 17:12 ` reckoner @ 2012-05-09 17:25 ` Vadim Zeitlin 0 siblings, 0 replies; 7+ messages in thread From: Vadim Zeitlin @ 2012-05-09 17:25 UTC (permalink / raw) To: Zsh Users [-- Attachment #1: Type: TEXT/PLAIN, Size: 664 bytes --] On Wed, 09 May 2012 10:12:18 -0700 reckoner <reckoner@gmail.com> wrote: r> On Wednesday, May 09, 2012 9:34:45 AM, Peter Stephenson wrote: r> > On Wed, 9 May 2012 09:00:43 -0700 r> > reckoner<reckoner@gmail.com> wrote: r> >>> ${x//[\(\)]/_} r> >> r> >> This last one doesn't work for me with or without the HIST_SUBST_PATTERN. r> > r> > Hmm... there's not a lot to go wrong unless your version of zsh is r> > very old. r> > r> > % zsh -f r> > % x="foo(bar())rod" r> > % print ${x//[\(\)]/_} r> > foo_bar___rod r> r> here's my version: zsh 4.3.11 (i686-pc-cygwin) FWIW the above commands work correctly with exactly the same zsh version for me... Regards, VZ [-- Attachment #2: Type: APPLICATION/PGP-SIGNATURE, Size: 196 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-05-09 18:01 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-05-09 14:01 how to use character range [] in substitution pattern :gs reckoner 2012-05-09 14:23 ` Jérémie Roquet 2012-05-09 14:38 ` Peter Stephenson 2012-05-09 16:00 ` reckoner 2012-05-09 16:34 ` Peter Stephenson 2012-05-09 17:12 ` reckoner 2012-05-09 17:25 ` Re[2]: " Vadim Zeitlin
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).