Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Jun 2010 12:22:56 -0700
From:      Chip Camden <sterling@camdensoftware.com>
To:        freebsd-questions@freebsd.org
Cc:        Carl Johnson <carlj@peak.org>
Subject:   Re: check for numeric content in a shell script (FreeBSD sh)
Message-ID:  <20100624192256.GF557@libertas.local.camdensoftware.com>
In-Reply-To: <20100624183933.GA50443@holstein.holy.cow>
References:  <4C22B3D7.6070102@comclark.com> <20100624033257.2D074BEA6@kev.msw.wpafb.af.mil> <87lja4mlme.fsf@cjlinux.localnet> <87hbksmk6y.fsf@cjlinux.localnet> <87d3vgmj1s.fsf@cjlinux.localnet> <20100624183407.GA49923@holstein.holy.cow> <20100624183933.GA50443@holstein.holy.cow>

next in thread | previous in thread | raw e-mail | index | archive | help
On Jun 24 08:39, Parv wrote:
> in message <20100624183407.GA49923@holstein.holy.cow>,
> wrote parv@pair.com thusly...
> >
> > #  Matches a number, either positive (without '+' sign) or
> > #  negative, which is either a whole number; or a real number
> > #  ending with decimal point, or a real number with or without
> > #  leading digits before the decimal point.
> .                 ^
> .                 ^  plural
> > ^
> > -?
> > (
> >   [0-9]  [.]? [0-9]*
> >     |
> >   [0-9]? [.]  [0-9]+
> .        ^
> .        ^  oops
> 
> Please change the immediately above regex portion to ...
> 
>   [0-9]* [.]  [0-9]+
> 
> 
>   - parv

We still need to be able to handle numbers without a decimal.  Try this:

	[0-9]*\.?[0-9]+

The question mark says "0 or 1"
> 
> > )
> > $
> 
> -- 
> 
> _______________________________________________
> 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"

-- 
Sterling (Chip) Camden
http://camdensoftware.com | http://chipstips.com | http://chipsquips.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100624192256.GF557>