[Israel.pm] number recognizer

Gaal Yahas gaal at forum2.org
Mon May 17 13:33:51 PDT 2004

On Mon, May 17, 2004 at 10:30:38PM +0300, Shlomo Yona wrote:
> > Regexp::Common::number.
> This is not exactly what I need (I think):
> I need a regular expression that will either accept or
> reject a string depending if the string is a number or not a
> number.
> The module you suggest serves as a parser for numbers.

This works:
	perl -MRegexp::Common=number -le 'print "a number!" if shift =~
             $RE{num}{real}' -- [any example from your list]

[the -- is only needed to let perl know negative numbers aren't switches.]

If the complaint about Regexp::Common being a parser is really about
its speed, well, I haven't benchmarked it. Give it a shot, it has some
clueful people for authors.

Gaal Yahas <gaal at forum2.org>

More information about the Perl mailing list