Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED,
	FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no
	version=3.4.1
X-Injected-Via-Gmane: http://gmane.org/
To: zsh-workers@zsh.org
From: Stephane Chazelas <stephane.chazelas@gmail.com>
Subject: Re: substitution groups and patterns i replace string (Emacs' \\1
 etc.)
Date: Tue, 8 Mar 2016 12:13:49 +0000
Lines: 22
Message-ID: <20160308121349.GA10628@chaz.gmail.com>
References: <87k2lk2ws9.fsf@debian.uxu>
 <20160303094140.705eb3bd@pwslap01u.europe.root.pri>
 <87a8mccfmv.fsf@debian.uxu>
 <CAHYJk3R_GwkJ2_ayNdZbT+8ByOC-hSRJrUV6Jch-w4uOVBjTsg@mail.gmail.com>
 <160307185234.ZM23145__47329.0627044209$1457405642$gmane$org@torch.brasslantern.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: usenet@ger.gmane.org
X-Gmane-NNTP-Posting-Host: 05448200.skybroadband.com
Content-Disposition: inline
In-Reply-To: <160307185234.ZM23145__47329.0627044209$1457405642$gmane$org@torch.brasslantern.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Seq: zsh-workers 38115

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

