Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Regular Expression from Hell

by perlmonkey (Hermit)
on Apr 15, 2004 at 15:34 UTC ( #345417=note: print w/replies, xml ) Need Help??


in reply to Regular Expression from Hell

I think what you are looking for is:
if( $test =~ /^\d{4}$/ ) { ... }
This will match:
'^': anchor start of string
\d{4}: exactly 4 digits
$: anchor end of string

if you know it is always going to be digits, then length would probably be eaiser:
if( length($test) == 4 ) { ... }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://345417]
help
Chatterbox?
[marto]: r@j you've yet to ask a question. This isn't a code writing service. PerlMonks for the Absolute Beginner/How do I post a question effectively?
[holli]: ah come on, marto. give him the codez already
LanX hires a killer

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (14)
As of 2017-10-23 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (280 votes). Check out past polls.

    Notices?