From owner-freebsd-questions@FreeBSD.ORG Thu Jan 23 22:42:24 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 68858F1F; Thu, 23 Jan 2014 22:42:24 +0000 (UTC) Received: from wonkity.com (wonkity.com [67.158.26.137]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0239F1515; Thu, 23 Jan 2014 22:42:23 +0000 (UTC) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.14.7/8.14.7) with ESMTP id s0NMgIaP081722; Thu, 23 Jan 2014 15:42:18 -0700 (MST) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.14.7/8.14.7/Submit) with ESMTP id s0NMgG97081719; Thu, 23 Jan 2014 15:42:16 -0700 (MST) (envelope-from wblock@wonkity.com) Date: Thu, 23 Jan 2014 15:42:16 -0700 (MST) From: Warren Block To: "'Devin Teske'" Subject: RE: awk programming question In-Reply-To: <04aa01cf187e$cfcf9ef0$6f6edcd0$@FreeBSD.org> Message-ID: References: <20140123185604.4cbd7611@gumby.homeunix.com> <04a201cf1878$8ebce540$ac36afc0$@FreeBSD.org> <04aa01cf187e$cfcf9ef0$6f6edcd0$@FreeBSD.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (wonkity.com [127.0.0.1]); Thu, 23 Jan 2014 15:42:18 -0700 (MST) 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 22:42:24 -0000 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