From owner-freebsd-questions@FreeBSD.ORG Thu Jan 23 23:45:10 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2AB8F698; Thu, 23 Jan 2014 23:45:10 +0000 (UTC) Received: from mx1.fisglobal.com (mx1.fisglobal.com [199.200.24.190]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E618919F6; Thu, 23 Jan 2014 23:45:09 +0000 (UTC) Received: from smarthost.fisglobal.com ([10.132.206.191]) by ltcfislmsgpa07.fnfis.com (8.14.5/8.14.5) with ESMTP id s0NNj3k6031425 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Thu, 23 Jan 2014 17:45:03 -0600 Received: from THEMADHATTER (10.242.181.54) by smarthost.fisglobal.com (10.132.206.191) with Microsoft SMTP Server id 14.3.174.1; Thu, 23 Jan 2014 17:45:01 -0600 From: Sender: Devin Teske To: "'Warren Block'" , "'Devin Teske'" References: <20140123185604.4cbd7611@gumby.homeunix.com> <04a201cf1878$8ebce540$ac36afc0$@FreeBSD.org> <04aa01cf187e$cfcf9ef0$6f6edcd0$@FreeBSD.org> In-Reply-To: Subject: RE: awk programming question Date: Thu, 23 Jan 2014 15:44:56 -0800 Message-ID: <04d201cf1895$20956890$61c039b0$@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQImboywfYAMtXakWRoTJ2P0ROJwWwJr8ryGAjfseSYDBtd9AwHDspKgAVvTlWgA1aCjm5mHTZOg Content-Language: en-us X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.11.87, 1.0.14, 0.0.0000 definitions=2014-01-23_05:2014-01-23,2014-01-23,1970-01-01 signatures=0 Cc: 'RW' , freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 23:45:10 -0000 > -----Original Message----- > From: Warren Block [mailto:wblock@wonkity.com] > Sent: Thursday, January 23, 2014 2:42 PM > To: 'Devin Teske' > Cc: 'RW'; freebsd-questions@freebsd.org > Subject: RE: awk programming question > > On Thu, 23 Jan 2014, dteske@FreeBSD.org wrote: > > > > > > >> -----Original Message----- > >> From: Warren Block [mailto:wblock@wonkity.com] > >> Sent: Thursday, January 23, 2014 12:57 PM > >> To: 'Devin Teske' > >> Cc: 'RW'; freebsd-questions@freebsd.org > >> Subject: RE: awk programming question > >> > >> On Thu, 23 Jan 2014, dteske@FreeBSD.org wrote: > >> > >>>> From: RW [mailto:rwmaillists@googlemail.com] > >>>> Note that awk supports +, but not newfangled things like *. > >>> > >>> With respect to regex, what awk really needs is the quantifier syntax... > >>> > >>> * = {0,} = zero or more > >>> + = {1,} = one or more > >>> {x,y} = any quantity from x inclusively up to y {x,} = any quantity > >>> from x or more > >> > >> I think RW meant to type that awk did not have the newfangled "?" for > >> non- greedy matches. > > > > But that one is supported. Tested on 9.2-R and 10.0-R... > > > > echo abbb | awk '{sub(/a?bbb/, ""); print}' # produces NULL output > > echo bbb | awk '{sub(/a?bbb/, ""); print}' # similarly produces NULL > > output > > > > Seems to be supported. But I'd really like to see {x,y} (the ? is > > equivalent to {0,1}). > > No, the non-greedy modifier to a standard quantifier: > > echo "abczabczabcz" | perl -ne '/(a.*z)/; print "$1\n"' > abczabczabcz > > echo "abczabczabcz" | perl -ne '/(a.*?z)/; print "$1\n"' > abcz Craziness! Wonder when that crept in. I'm not entirely sure how I feel about that -- in terms of readability, I'm not sure if the following is more readable: /(a[^z]*z)/ -- Devin _____________ The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.