Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: regex for numbers

by Discipulus (Canon)
on Apr 07, 2021 at 17:30 UTC ( [id://11130966]=note: print w/replies, xml ) Need Help??


in reply to regex for numbers

Hello BernieC,

you got obvious and wise answers; I'm not here for this :) What about { local $@; eval 0 + $maybe_a_number ... }?

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: regex for numbers
by choroba (Cardinal) on Apr 07, 2021 at 18:59 UTC
    Perl happily accepts 0 + '1.1.' (well, it warns, but it doesn't throw an exception). So, eval alone isn't enough.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11130966]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-19 07:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found