Ryan Fischer wrote:
> 
> You wrote:
> > How short kan you make a program (oneliner?) that:
> >
> > * checks if a password is 5 characters long or more
> > * checks if the password contains at least 3 alpha chars (a-zA-Z)
> > * checks if the password contains at least 2 numbers (0-9)
> >
> > I needed 5 lines of code how about you guys?
> 
> This should do it I think:
> 
> /[a-zA-Z]/==3&&/[0-9]/==2&&/^.{5,}$/;
> 
> (Given that the password is in $_, of course.)


$ perl -le'$_ = "a1b2c";
if ( /[a-zA-Z]/==3&&/[0-9]/==2&&/^.{5,}$/ )
{ print "TRUE" } else { print "FALSE" }'
FALSE
$ perl -le'$_ = "a1b2c3d";
if ( /[a-zA-Z]/==3&&/[0-9]/==2&&/^.{5,}$/ )
{ print "TRUE" } else { print "FALSE" }'
FALSE


Think again.  :-)

John
-- 
use Perl;
program
fulfillment

Reply via email to