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

Re: regular expression

by gav^ (Curate)
on Jun 08, 2002 at 03:25 UTC ( [id://172733]=note: print w/replies, xml ) Need Help??


in reply to regular expression to match numbers

If it's a number, treat it like one:
if ($x >= 1 && $x <= 10) { print "Correct match"; } else { print "Incorrect"; }
I'm not sure why you'd want to write a regular expression for this, unless it was homework :) If you insist, something like this would do the trick:
if ($x =~ /^([1-9]|10)$/) { # etc }
This uses ^ and $ to anchor the expression to the whole string and the brackets to restrict the alternation. See perlre for more help.

gav^

Replies are listed 'Best First'.
Re: Re: regular expression
by Anonymous Monk on Jun 08, 2002 at 03:35 UTC
    Thank you ...I am going to see that link. vana

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-19 13:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found