[Israel.pm] number recognizer

Shlomo Yona shlomo at cs.haifa.ac.il
Mon May 17 13:49:00 PDT 2004


On Mon, 17 May 2004, Gaal Yahas wrote:

> 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.

I want to see the regex that can do it. I'll look into the
code. 

Thanks.


-- 
Shlomo Yona
shlomo at cs.haifa.ac.il
http://cs.haifa.ac.il/~shlomo/




More information about the Perl mailing list