Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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 ) { ... }

Comment on Re: Regular Expression from Hell
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2015-11-25 05:23 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (671 votes), past polls