From owner-freebsd-questions@FreeBSD.ORG Sun Dec 5 08:56:35 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 541EC106566B for ; Sun, 5 Dec 2010 08:56:35 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from sola.nimnet.asn.au (paqi.nimnet.asn.au [115.70.110.159]) by mx1.freebsd.org (Postfix) with ESMTP id A8A0D8FC15 for ; Sun, 5 Dec 2010 08:56:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by sola.nimnet.asn.au (8.14.2/8.14.2) with ESMTP id oB58uUkh060607; Sun, 5 Dec 2010 19:56:31 +1100 (EST) (envelope-from smithi@nimnet.asn.au) Date: Sun, 5 Dec 2010 19:56:30 +1100 (EST) From: Ian Smith To: Gary Kline In-Reply-To: <20101205073614.AE4C01065785@hub.freebsd.org> Message-ID: <20101205194739.U20283@sola.nimnet.asn.au> References: <20101205073614.AE4C01065785@hub.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: perryh@pluto.rain.com, freebsd-questions@freebsd.org Subject: Re: regex question.... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Dec 2010 08:56:35 -0000 In freebsd-questions Digest, Vol 339, Issue 11, Message: 30 On Sat, 4 Dec 2010 18:23:08 -0800 Gary Kline wrote: > On Sat, Dec 04, 2010 at 05:56:59PM -0800, perryh@pluto.rain.com wrote: > > Joshua Gimer wrote: > > > > > On Sat, Dec 4, 2010 at 5:26 PM, Gary Kline wrote: > > > > I have tried :1,$/s/[0-9]][0-9][0-9]/foo/g > > > Why not just %s/[0-9]*/foo/g > > > > Too broad -- it will match the null string. (* means "zero or more > > instances of" whatever preceded it.) > > > > Best RE I know for integers is > > > > [1-9][0-9]* > > > > (or replace the 1 with a 0 if the strings in question might have > > leading zeros). > > > YES, and Perry get an A+; the numbers do start with 1; no > leading 0's. Except 0 itself? :) You originally specified "ints from 0 to some N." I think you want either [0-9][0-9]* or just [0-9]+ (one or more digits) cheers, Ian