Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Reg Ex exercise

by thundergnat (Deacon)
on Dec 05, 2012 at 16:26 UTC ( #1007321=note: print w/replies, xml ) Need Help??


in reply to Reg Ex exercise

Seems like fairly arbitrary specs for what is or isn't a number. Ah well. Don't expect this to work for scientific notation, complex numbers, or anything else that isn't explicitly tested here.

printf "%s is %sa number.\n", $_, /^-?\d+(?:\.\d+)?$/ ? '' : 'NOT ' for qw/4 -7 0.656 -67.35555 5. 56F .32 -.04/;
4 is a number.
-7 is a number.
0.656 is a number.
-67.35555 is a number.
5. is NOT a number.
56F is NOT a number.
.32 is NOT a number.
-.04 is NOT a number.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007321]
help
Chatterbox?
[ravi45722]: can i get current date using Joda time format
[ravi45722]: Ex: EEE MMM dd HH:mm:ss.SSS yyyy
[ravi45722]: Fri Mar 24 11:54:55.234 2017

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2017-03-24 06:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (296 votes). Check out past polls.