Results 1 to 2 of 2

Thread: Better way to validate password with regex

  1. #1

    Thread Starter
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Better way to validate password with regex

    The password requirements are:

    Must be at least 8 characters
    Must include at least one number
    Must be alpha-numeric

    I came up with this, but it seams overly complicated for what I'm trying to do. Can anybody improve it?

    Code:
    "^(\d\w{7,}|\w\d\{6,}|\w{2}\d\w{5,}|\w{3}\d\w{4,}|\w{4}\d\w{3,}|\w{5}\d\w{2,}|\w{6}\d\w{1,}|\w{7}\d|\w{8}\w*\d\w*)$"

  2. #2

    Thread Starter
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Better way to validate password with regex

    This came from a different board, looks good.
    Code:
    "^\w{8,}(?<=\w*\d\w*)$"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width