From xemacs-m  Wed Aug 20 11:47:19 1997
Received: from server.sensei.co.uk (server.sensei.co.uk [193.132.124.5])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id LAA20058
	for <xemacs-beta@xemacs.org>; Wed, 20 Aug 1997 11:47:17 -0500 (CDT)
Received: from planet.sensei.co.uk (root@planet.sensei.co.uk [195.92.19.3]) by server.sensei.co.uk (8.8.5/8.8.2) with ESMTP id RAA05572; Wed, 20 Aug 1997 17:46:48 +0100
Received: from cerise.sensei.co.uk (glynn@muvies.demon.co.uk [158.152.66.14]) by planet.sensei.co.uk (8.8.2/8.8.2) with ESMTP id RAA08432; Wed, 20 Aug 1997 17:45:58 +0100
Received: (from glynn@localhost) by cerise.sensei.co.uk (8.8.5/8.8.2) id RAA01802; Wed, 20 Aug 1997 17:50:45 +0100
Date: Wed, 20 Aug 1997 17:50:45 +0100
Message-Id: <199708201650.RAA01802@cerise.sensei.co.uk>
From: Glynn Clements <glynn@sensei.co.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: Pete Ware <ware@cis.ohio-state.edu>
CC: xemacs-beta@xemacs.org
Subject: Re: New regex syntax
In-Reply-To: <vwmaficn86j.fsf_-_@calico.cis.ohio-state.edu>
References: <87lo21hzm0.fsf@bittersweet.inetarena.com>
	<vwmd8n8n9up.fsf@calico.cis.ohio-state.edu>
	<199708201601.RAA01648@cerise.sensei.co.uk>
	<vwmaficn86j.fsf_-_@calico.cis.ohio-state.edu>
X-Mailer: VM 6.33 under 20.3 "Bratislava" XEmacs  Lucid (beta18)


Pete Ware wrote:

> Am I being pedantic or stupid?  Actually, isn't:
> 
> 	a*?	==> ""
> 	a??	==> ""
> 	a+?	==> "a"
> 
> In other words, why do this or what don't I understand?

a*? matches "", but also "a", "aa", "aaa", ...

So does a*, but a*? chooses the shortest match, whereas a* chooses the 
longest match.

Consider matching against XYZYZ

	X.*Z	==> XYZYZ
	X.*?Z	==> XYZ

Without *? you would have to use X[^Z]*Z instead. Not in itself a big
deal, but if the trailing regex is more complex, then the advantages
become much more significant.

-- 
Glynn Clements <glynn@sensei.co.uk>

