From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1474 invoked from network); 11 Feb 2006 19:20:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 11 Feb 2006 19:20:21 -0000 Received: (qmail 79581 invoked from network); 11 Feb 2006 19:20:16 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 11 Feb 2006 19:20:16 -0000 Received: (qmail 13784 invoked by alias); 11 Feb 2006 19:20:13 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22232 Received: (qmail 13774 invoked from network); 11 Feb 2006 19:20:12 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 11 Feb 2006 19:20:12 -0000 Received: (qmail 79285 invoked from network); 11 Feb 2006 19:20:12 -0000 Received: from vms044pub.verizon.net (206.46.252.44) by a.mx.sunsite.dk with SMTP; 11 Feb 2006 19:20:07 -0000 Received: from candle.brasslantern.com ([71.116.81.225]) by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPA id <0IUJ00K6JF1IBLX2@vms044.mailsrvcs.net> for zsh-workers@sunsite.dk; Sat, 11 Feb 2006 13:20:07 -0600 (CST) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id k1BJK5MR006034 for ; Sat, 11 Feb 2006 11:20:05 -0800 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id k1BJK5lv006033 for zsh-workers@sunsite.dk; Sat, 11 Feb 2006 11:20:05 -0800 Date: Sat, 11 Feb 2006 19:20:04 +0000 From: Bart Schaefer Subject: Re: Regexp replace on all arguments. In-reply-to: <20060211182105.GA7789@lxlabs.com> To: Zsh-workers Message-id: <1060211192004.ZM6032@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <20060211173626.GA6863@lxlabs.com> <20060211173818.GA4965@sc> <20060211182105.GA7789@lxlabs.com> Comments: In reply to Ligesh "Re: Regexp replace on all arguments." (Feb 11, 11:51pm) On Feb 11, 11:51pm, Ligesh wrote: > Subject: Re: Regexp replace on all arguments. > > On Sat, Feb 11, 2006 at 05:38:19PM +0000, Stephane Chazelas wrote: > > winexec() { > > local cmd=$1 > > shift || return > > argv=("${@//#\/(#b)([a-zA-Z])\//$match:}") > > "$cmd" "$@" > > } > > > > I couldn't get it to work. There is no substitution happening at all. winexec () { setopt localoptions extendedglob local cmd=$1 shift || return argv=("${@//#\/(#b)([a-zA-Z])\//$match:}") "$cmd" "$@" } > What's the /#? You're parsing it wrong. @ The variable to expand // Replace all occurrences of #\/(#b)([a-zA-Z])\/ this pattern / with $match: this expansion (see "backreference" below) > what's (#b)? The pattern is # Anchor at beginning \/ a slash (#b) activate "backreferences" ([a-zA-Z]) create a backreference to one alphabetic \/ another slash The backreference stuff requires extendedglob. It's actually not useful to use the // for replace-all because there can only be one match when anchored at the beginning, so just ${@/#.../...} would have been OK. (This question really should have been asked on zsh-users.)