Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Regex for a Complex Password

Last post 03-29-2007, 12:06 PM by mash. 16 replies.
Page 2 of 2 (17 items)   < Previous 1 2
Sort Posts: Previous Next
  •  03-29-2007, 7:17 AM 28594 in reply to 28552

    Re: Regex for a Complex Password

    i tried my best to include the above check in this regex ..  ^(?!.*(.)\1{2})(((?=.*?[a-zA-Z])(?=.*?\d))|((?=.*?[a-zA-Z])(?=.*?[!@#$%^&*()+=._-]))|((?=.*?[!@#$%^&*()+=._-])(?=.*?\d)))([-!@#$%^&*()+=._\da-zA-Z]){8,}$  ... Never worked for me .. Can u please help !!

     

    Thanks

  •  03-29-2007, 12:06 PM 28602 in reply to 28594

    Re: Regex for a Complex Password

    karunkarthik:

    i tried my best to include the above check in this regex ..  ^(?!.*(.)\1{2})(((?=.*?[a-zA-Z])(?=.*?\d))|((?=.*?[a-zA-Z])(?=.*?[!@#$%^&*()+=._-]))|((?=.*?[!@#$%^&*()+=._-])(?=.*?\d)))([-!@#$%^&*()+=._\da-zA-Z]){8,}$  ... Never worked for me .. Can u please help !!

     

    Thanks

    Ok intergrating Sergei's regex with mine the final regex to satisfy all your requirements is

     ^(?:(?:(?=.*?[a-zA-Z])(?=.*?\d))|(?:(?=.*?[a-zA-Z])(?=.*?[!@#$%^&*()+=._-]))|(?:(?=.*?[!@#$%^&*()+=._-])(?=.*?\d)))(?:([-!@#$%^&*()+=._\da-zA-Z])(?!(.*?\1){2})){8,}$

    After this point you are going to have to start helping yourself.  You do realize that we are not sitting there next to you watching what you are trying to do, right? How you are implementing and what values you are testing with is something known only to you.  You didn't even say which version of Struts you were using.  Saying it never worked for you doesn't tell us anything. There is nothing wrong syntax-wise with any regexes you have been provided and while miscommunication may not have provided for all of the specifications in the previous replies that would have worked  in every test case, they were certainly more than enough to validate some test cases.  All numbers or all as negative test letter for instance. If you are saying that even those cases passed when they should have failed  it is not because of the regex, but the way you have failed to implement something needed for this to work.  You said before that you didn't know what regex engine you were using, assuming your the only one working on this validation, did you even import the ORO library into your code? Remember we can't see what you are doing.  I have not worked with Struts for several years but it was using Jakarta ORO. They last two regexes I've provided you both worked with ORO when tested at http://jakarta.apache.org/oro/demo.html using my own test values. If you are using some other regex library you are going to research and find out what syntax is does and does not support.

    My advice, if you haven't already read up on how to implement the validation.xml with Struts, then try a very simple test.  Like used the regex ^abc$ to allow only abc to be entered to make sure you code is at least correct. If entering DEF passed then something is not set up correctly. Get that working before trying to used the full password regex.

     


    Michael

    "In theory, theory and practice are the same. In practice, they are not."
    Albert Einstein
Page 2 of 2 (17 items)   < Previous 1 2
View as RSS news feed in XML