http://www.perlmonks.org?node_id=244337


in reply to specific numbers of digits

<KISS>
$zip =~ m/\d{5,5}/;
</KISS>
from the frivolous to the serious

Replies are listed 'Best First'.
Re: Re: specific numbers of digits
by awkmonk (Monk) on Mar 19, 2003 at 14:30 UTC

    Sorry to point this out, but..

    $x = "123456"; if ( $x =~ /\d{5,5}/ ) { print "wrong"; }

    Still matches 123456

    This will do the trick

    $x = "123456"; if ( $x =~ /^\d{5}$/ ) { print "right"; }