From owner-freebsd-questions@FreeBSD.ORG Sun Dec 5 04:32:59 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 415E9106566C for ; Sun, 5 Dec 2010 04:32:59 +0000 (UTC) (envelope-from kline@thought.org) Received: from thought.org (plato.thought.org [209.180.213.209]) by mx1.freebsd.org (Postfix) with ESMTP id 0D9888FC08 for ; Sun, 5 Dec 2010 04:32:58 +0000 (UTC) Received: by thought.org (Postfix, from userid 1001) id B63A4E80AA3; Sat, 4 Dec 2010 20:32:57 -0800 (PST) Date: Sat, 4 Dec 2010 20:32:57 -0800 From: Gary Kline To: xSAPPYx Message-ID: <20101205043257.GA3854@thought.org> References: <20101205002602.GA27499@thought.org> <4cfaf16b./uHAeLS0wfpxq8FB%perryh@pluto.rain.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: With 24 years of service to the Unix community. User-Agent: Mutt/1.5.20 (2009-06-14) Cc: perryh@pluto.rain.com, jgimer@gmail.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 04:32:59 -0000 On Sat, Dec 04, 2010 at 06:49:45PM -0800, xSAPPYx wrote: > On Sat, Dec 4, 2010 at 17:56, 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). > > _______________________________________________ > > freebsd-questions@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" > > > > Also, the + operator means '1 or more' but needs escaped: %s/[0-9]\+/foo/g Okay. I thought that the + must be perl-only regex... . Then, nutshell, the most simple expression [fewest keystrokes] would be: %s/[1-0][0-9]*/foo/g > -- Gary Kline kline@thought.org http://www.thought.org Public Service Unix Journey Toward the Dawn, E-Book: http://www.thought.org The 7.97a release of Jottings: http://jottings.thought.org