Subject: Re: substitution groups and patterns i replace string (Emacs' \\1 etc.)
From: Stephane Chazelas <[email-masked]>
To: [email-masked]
Date: Tue, 8 Mar 2016 12:13:49 +0000
List-Id: Zsh Workers List <zsh-workers.zsh.org>

2016-03-07 18:52:34 -0800, Bart Schaefer:
> On Mar 6,  8:15am, Mikael Magnusson wrote:
> }
> } % echo ${a//(#b)([aoeui])/${(U)match[1]}}
> 
> It's actually quite simple to make $1, $2, ... refer to the values in
> the $match array during ${v//p/r} substitutions.  This would make the
> syntax look very perl-ish, but would mean you can't combine backrefs
> with expansions of the normal positional parameters.
[...]

Note that ksh93 does support

$ var=aaabbcdd
$ print -r -- "${var//@(?)\1/2<\1>}"
2<a>a2<b>c2<d>

That is \1 both as a back-reference in the pattern and capture
group for the substitution.

-- 
Stephane