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

Re: regular expressions and setting variables?



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