Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2016-12-03 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (56 votes). Check out past polls.