From owner-freebsd-questions Tue Oct 23 10:45:29 2001 Delivered-To: freebsd-questions@freebsd.org Received: from mobil.cz (diana.mobil.cz [195.39.16.12]) by hub.freebsd.org (Postfix) with ESMTP id 070A137B401 for ; Tue, 23 Oct 2001 10:45:26 -0700 (PDT) Received: from ester.mobil.cz ([194.228.207.250]) by mobil.cz (8.11.6/8.11.0) with ESMTP id f9NHjJv28697 for ; Tue, 23 Oct 2001 19:45:19 +0200 Received: from roman.mobil.cz ([10.2.0.89]) by ester.mobil.cz (Lotus Domino Release 5.0.7) with ESMTP id 2001102319422052:328 ; Tue, 23 Oct 2001 19:42:20 +0200 Received: (from roman@localhost) by roman.mobil.cz (8.11.6/8.11.6) id f9NHnef08987 for freebsd-questions@freebsd.org; Tue, 23 Oct 2001 19:49:40 +0200 (CEST) (envelope-from neuhauser@mobil.cz) X-Authentication-Warning: roman.mobil.cz: roman set sender to neuhauser@mobil.cz using -f Date: Tue, 23 Oct 2001 19:49:40 +0200 From: Roman Neuhauser To: freebsd-questions@freebsd.org Subject: Re: regex(3), re_format(7) and shortest match Message-ID: <20011023194940.A8947@roman.mobil.cz> Mail-Followup-To: freebsd-questions@freebsd.org References: <3BD5A7F4.748285AA@verizon.net> Mime-Version: 1.0 In-Reply-To: <3BD5A7F4.748285AA@verizon.net> User-Agent: Mutt/1.3.23i X-MIMETrack: Itemize by SMTP Server on ester/Mobil(Release 5.0.7 |March 21, 2001) at 10/23/2001 07:42:20 PM, Serialize by Router on ester/Mobil(Release 5.0.7 |March 21, 2001) at 10/23/2001 07:42:28 PM, Serialize complete at 10/23/2001 07:42:28 PM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > Date: Tue, 23 Oct 2001 10:25:08 -0700 > From: Shill > To: freebsd-questions@freebsd.org > Subject: regex(3), re_format(7) and shortest match > > Say I have the string: > "yo hiphop fun" > > I want to isolate individual "" subexpressions. > > The naive regex I used was: () > > Of course, that doesn't work since it returns the longest match, in my > case " hiphop ". > > I battled with bracket expressions and collating elements for three > hours to no avail. Can anyone tell me how to achieve the shortest match? > > i.e. the first call to regexec() would return "" and the > second would return "". Try this: () HTH, Roman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message