Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: how to use character range [] in substitution pattern :gs





On 5/9/2012 7:38 AM, Peter Stephenson wrote:
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//[\(\)]/_}


This last one doesn't work for me with or without the HIST_SUBST_PATTERN.

Thanks!



Messages sorted by: Reverse Date, Date, Thread, Author