From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26372 invoked from network); 31 Aug 1999 14:42:41 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 31 Aug 1999 14:42:41 -0000 Received: (qmail 12805 invoked by alias); 31 Aug 1999 14:42:34 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7579 Received: (qmail 12798 invoked from network); 31 Aug 1999 14:42:33 -0000 X-Envelope-Sender-Is: Andrej.Borsenkow@mow.siemens.ru (at relayer thoth.mch.sni.de) From: "Andrej Borsenkow" To: "Sven Wischnowsky" , Subject: RE: PATCH: new parameter expansion type? Date: Tue, 31 Aug 1999 17:18:21 +0400 Message-ID: <000001bef3b3$4c738fd0$21c9ca95@mow.siemens.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal In-Reply-To: <199908301038.MAA20917@beta.informatik.hu-berlin.de> X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 > > > > Remember discussion of backreference in new regexp implementation? > I think, we > > should unify it with ${.../...} & Co code. There are two possibilities: > > Sure I remember that, but it's a different thing -- or how would you > do an if-then-else with `${.../...}'? Or are you suggesting > `${.../pat/repl-then/repl-else}'? Hm. > No. What I suggest is 1. enable use of subpatterns 2. save the results of last pattern match in defined variables, e.g. $MATCH (scalar) for a whole match and $match (array) for subpatterns. Yes, it has som eimpact, but e.g. in case of $foo == bar MATCH is reduntant (we match the whole string anyway) and we can use option to turn it off. 3. now these variables can be used in ${.../...} and in ${...^...} in replacement part. So, you can write ${foo^$~bar^$baz^$MATCH}. Or ${foo/\([[:alpha:]]##\)\([[:letter:]]\)/$match[1]:$match[2]} 4. And these variables can be also used outside of expansion: case $foo in any_pattern) print $match[3] /andrej