From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16314 invoked from network); 21 Mar 2001 14:23:26 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 21 Mar 2001 14:23:26 -0000 Received: (qmail 8232 invoked by alias); 21 Mar 2001 14:23:06 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3712 Received: (qmail 8221 invoked from network); 21 Mar 2001 14:23:05 -0000 Date: Wed, 21 Mar 2001 14:23:03 +0000 From: Adam Spiers To: zsh users mailing list Subject: non-greedy matching? Message-ID: <20010321142303.B8924@thelonious.new.ox.ac.uk> Reply-To: Adam Spiers Mail-Followup-To: zsh users mailing list Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.4i X-Home-Page: http://www.new.ox.ac.uk/~adam/ X-OS: RedHat Linux Sorry, I seem to be coming out with a lot of dumb questions recently. In my quest to improve my zsh startup time, I noticed to my horror that when I initially coded prompt_adam2_setup, I made it invoke perl no less than three times. Eliminating one of them is fairly easy; however the other two invocations are: ..... | perl -pe 's/%{.*?%}//g' They are done in order to strip control characters from a prompt so that its display width can be determined. At first I thought that it would surely be easy to avoid this, but I still haven't come up with a quick replacement, since neither zsh nor sed seem to be able to do non-greedy matching. Any ideas? The only alternatives I've come up with are: foo=$(print -P "$prompt_string") bar="${foo//^[[[0-9;]##m/}" the string and then strip out ANSI escape sequences, or maybe to use the (^(...)) extended glob somehow, but I haven't managed to get the latter working. It would be nice if zsh could do non-greedy though.