Regular Expression for a password

Discussion in 'ASP .Net' started by Joe, Feb 11, 2008.

  1. Joe

    Joe Guest

    Hello,

    I want to verify that a password is:
    - Minimum 7 characters (can be any character)
    - Includes at least 1 number.

    I thought this would work but it does seem to:
    ^(?=.*[a-z])(?=.*[A-Z]).{7,}$

    Thanks,
    Joe
     
    Joe, Feb 11, 2008
    #1
    1. Advertising

  2. Hello Joe,

    > Hello,
    >
    > I want to verify that a password is:
    > - Minimum 7 characters (can be any character)
    > - Includes at least 1 number.
    > I thought this would work but it does seem to:
    > ^(?=.*[a-z])(?=.*[A-Z]).{7,}$
    > Thanks,
    > Joe


    There is no check for a number in there at all....

    ^(?=.*[0-9]).{7,}$

    should do the trick.

    --
    Jesse Houwing
    jesse.houwing at sogeti.n
     
    Jesse Houwing, Feb 11, 2008
    #2
    1. Advertising

  3. Joe

    lue Guest

    Joe
    see this link
    http://davidhayden.com/blog/dave/archive/2004/09/25/501.aspx
    password complexity in your applications:
    ^.*(?=.{7,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$

    The regular expression enforces the following rules:

    a.. Must be at least 7 characters
    b.. Must contain at least one one lower case letter, one upper case
    letter, one digit and one special character
    c.. Valid special characters (which are configurable) are - @#$%^&+=


    Regards

    Lue

    "Joe" <> wrote in message
    news:...
    > Hello,
    >
    > I want to verify that a password is:
    > - Minimum 7 characters (can be any character)
    > - Includes at least 1 number.
    >
    > I thought this would work but it does seem to:
    > ^(?=.*[a-z])(?=.*[A-Z]).{7,}$
    >
    > Thanks,
    > Joe
    >
     
    lue, Feb 11, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    2
    Views:
    2,354
  2. JJ
    Replies:
    7
    Views:
    6,211
    ThunderMusic
    Sep 19, 2006
  3. =?Utf-8?B?SXZhbiBBYnJhbW92?=

    Regular expression for password

    =?Utf-8?B?SXZhbiBBYnJhbW92?=, Jan 29, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    345
    Jonathan Wood
    Jan 29, 2007
  4. AAaron123
    Replies:
    2
    Views:
    2,328
    AAaron123
    Jan 16, 2009
  5. AAaron123
    Replies:
    1
    Views:
    1,389
    Oriane
    Jan 16, 2009
Loading...

Share This Page