SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Check Password

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Check Password

    I am trying to create a RegEx pattern to check a string, but can't figure out how to get mine to work. I want it to be at least 8 characters and have a single uppercase, a single special character (!@#), and the rest lowercase or numbers. My single, I mean one, not at least one.

    Here is what I have so far (this doesn't seem to work) -
    Code:
    ^(?=.*[!@#])(?=.*[A-Z])[a-z0-9]{8,}$
    If I try the following, it works, but I think the period means that the remaining 6+ characters can be pretty much any character except for newline -
    Code:
    ^(?=.*[!@#])(?=.*[A-Z]).{8,}$

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This pattern is not maintainable. I think that you should do it without regex. You can parse the password and count the totals of upper, lower, special and other chars.


Bookmarks

Posting Permissions

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