Abigail sprak:
> 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;

To make it consistent with earlier offerings from Makepeace, Sec
and me (Aristotle's is different in that it does not accept '-'
and '_') may I suggest:

  /^(?=.{6})             # At least 6 characters long.
    (?=.*[a-z])          # Contains a lowercase letter.
    (?=.*[A-Z])          # Contains an uppercase letter.
    (?=.*[0-9])          # Contains a digit.
    (?!.*[^-\w])         # Doesn't contain an invalid char.
    (?!.{15})            # Doesn't contain 15 characters.
  /xs;

Following Abigail's style, my chopsticks solution can be made more
palatable (if less pleasing to the eye):

     length() > 5        # At least 6 characters long.
  && tr/a-z//            # Contains a lowercase letter.
  && tr/A-Z//            # Contains an uppercase letter.
  && tr/0-9//            # Contains a digit.
  && !tr/-_a-zA-Z0-9//c  # Doesn't contain an invalid char.
  && length() < 15       # Doesn't contain 15 characters.

/-\



http://mobile.yahoo.com.au - Yahoo! Mobile
- Exchange IMs with Messenger friends on your Telstra or Vodafone mobile phone.

Reply via email to