On 13 December 2001 13:29, Kim Schulz [mailto:[EMAIL PROTECTED]] wrote
> How short kan you make a program (oneliner?) that:
> 
> * checks if a password is 5 characters long or more

As noted, this is covered below...

> * 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?

(Taking my basic idea and then noticing others had realised that >= 2 is the
same as > 1!)

If you are prepared to change $_:

if (y/a-zA-Z//>2&&y/0-9//>1) {          # 24 chars for the test
        print "not valid";
}


If you can't change $_, you need the c opt on the y's, hence:

if (y/a-zA-Z//c>2&&y/0-9//c>1) {        # 26 chars for the test
        print "not valid";
}


(Which are shorter than the regex versions...)

Richard Cox 
Senior Software Developer 
Dell Technology Online 
All opinions and statements mine and do not in any way (unless expressly
stated) imply anything at all on behalf of my employer

Reply via email to