Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 wandering the Monastery: (11)
As of 2014-11-23 22:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (134 votes), past polls