in reply to Reg Ex exercise
Hello keesturam, Im sure it could be simplified more, but this is what I came up with! hope it helps :)
if($input =~ /^(-?)((0|\d+).)?\d+$/) { print ("Yes, it is a number\n"); }
UPDATE: don't need that 0 in there,
if($input =~ /^(-?)(\d+.)?\d+$/)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reg Ex exercise
by thundergnat (Deacon) on Dec 05, 2012 at 16:49 UTC | |
|
Re^2: Reg Ex exercise
by keesturam (Initiate) on Dec 05, 2012 at 16:27 UTC | |
by Rudolf (Pilgrim) on Dec 05, 2012 at 16:40 UTC |