From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19528 invoked from network); 21 Mar 2001 15:47:34 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 21 Mar 2001 15:47:34 -0000 Received: (qmail 28488 invoked by alias); 21 Mar 2001 15:47:16 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3715 Received: (qmail 28474 invoked from network); 21 Mar 2001 15:47:14 -0000 Message-ID: <20010321154714.31702.qmail@web9305.mail.yahoo.com> Date: Wed, 21 Mar 2001 15:47:14 +0000 (GMT) From: =?iso-8859-1?q?Oliver=20Kiddle?= Subject: Re: non-greedy matching? To: Adam Spiers , zsh users mailing list In-Reply-To: <20010321142303.B8924@thelonious.new.ox.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit --- Adam Spiers wrote: > Any ideas? The only alternatives I've come up with are: > > foo=$(print -P "$prompt_string") > bar="${foo//^[[[0-9;]##m/}" I should have thought about this before replying the first time but I didn't until after Sven's e-mail. If you have extendedglob set, you can do: ${(%%)${PS1//%\{(^*%\}*)%\}/}} Doing the replace before the prompt expansion allows this to match the %{...%} instead of the escape sequence. If you have any parameters which when substituted include escape sequences, you may need to use (e) before PS1 to expand these first. I trust this more than the sed because it can do (^*%\}*) which matches anything which doesn't contain %} to force the non-greedy behaviour. Oliver ____________________________________________________________ Do You Yahoo!? Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your free @yahoo.ie address at http://mail.yahoo.ie