> Abigail <[EMAIL PROTECTED]> writes:
> 
> > On Mon, Feb 17, 2003 at 07:40:46PM -0000, Matt Groves wrote:
> >
> > Hello,
> > 
> > I'm looking for the shortest, cleverest possible solution to this.  When
> > changing a password, I need a RegExp which will ensure the following
> > criteria :
> > 
> > 1. It must be at least 6 characters
> > 
> > 2. It must contain at least one lower case letter [a-z]
> > 
> > 3. It must contain at least one upper case letter [A-Z]
> > 
> > 4. It must contain at least one number [0-9]
> > 
> > 5. Optionally, it can cover for accepted non-alphanumeric chars such as
> > "_", "-" etc (but not "#"), and a maximum password length of 14
> > characters
> 
> I'm not going to claim this is the shortest solution, but this
> is very straightforward (and untested):
> 
>     /^(?=.{6})        # At least 6 characters long.
>       (?=.*[a-z])     # Contains a lowercase letter.
>       (?=.*[A-Z])     # Contains an uppercase letter.
>       (?=.*[0-9])     # Contains a digit.
>       (?=.*[-_])      # Contains a dash or an underscore.
>       (?!.{15})       # Doesn't contain 15 characters.
>     /xs;

Hi all,

A possible improvement is to ensure that a limited set of
characters are accepted.  For example, characters in the
ASCII range 0-31 make difficult to type passwords.  This
does substantially reduce the number of possible passwords.

    /^(?=.{6})        # At least 6 characters long.
      (?=.*[a-z])     # Contains a lowercase letter.
      (?=.*[A-Z])     # Contains an uppercase letter.
      (?=.*[0-9])     # Contains a digit.
      (?=.*[-_])      # Contains a dash or an underscore.
      (?!.{15})       # Doesn't contain 15 characters.
      [-_a-zA-Z0-9]*$ # Acceptable characters 
    /xs;

This may implement an optional extension of item 5:

    ...it can cover for accepted non-alphanumeric chars
    such as "_", "-" etc (but not "#"), ...

Jonathan Paton

=====
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 >=~/ \S\S \S\S /gx) {m/(
\d+) (.+) /x,, vec$ J,$p +=$2 ,8,= $c+= +$1} warn $J,,

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

Reply via email to