Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Reg Ex exercise

by grondilu (Pilgrim)
on Dec 05, 2012 at 16:29 UTC ( #1007326=note: print w/ replies, xml ) Need Help??


in reply to Reg Ex exercise

You can put your OR inside your regex:

use strict; use warnings; print "Enter the number to check if it is actually a number: "; while (<STDIN>) { chomp; if (/^(\d+|\d+.\d+|-\d+|-\d+.\d+)$/) { print "Yes, it is a number\n"; } else { print "No, it is not a number\n"; } print "Give another input: "; }


Comment on Re: Reg Ex exercise
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-08-21 05:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (127 votes), past polls