Robin Houston <[EMAIL PROTECTED]> writes: > On Thu, Dec 13, 2001 at 02:29:14PM +0100, Kim Schulz 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) > > Well, the first condition is redundant. :-) > > How about > for ($password) {die if 3>y/a-zA-z//c || 2>y/0-9//c} > ? > > > It's interesting to try & do it as a single regex. The shortest > I've found is: > > /(?=[a-z].*[a-z].*[a-z]).*\d.*\d/
/(?=(.*[a-z])){3}(.*\d){2}/i (you also need the i I guess). [...] -- Ariel Scolnicov |"GCAAGAATTGAACTGTAG" | [EMAIL PROTECTED] Compugen Ltd. | +++ THIS SPACE TO LET +++ \ We recycle all our Hz 72 Pinhas Rosen St. |Tel: +972-3-7658117 (Main office)`--------------------- Tel-Aviv 69512, ISRAEL |Fax: +972-3-7658555 http://3w.compugen.co.il/~ariels