in reply to Regular Expression from Hell
I think what you are looking for is:
'^': 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:
This will match:if( $test =~ /^\d{4}$/ ) { ... }
'^': 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 ) { ... }
|
---|
In Section
Seekers of Perl Wisdom