Regex Password Validation

Posted on 2009-12-18
Last Modified: 2012-05-08
Can someone provide me with a regex string that I can use in C# for password validation?  The requirements are as follows:

Character length: 7-30.
Must contain at least one number.
Must contain at least one symbol/special character.
Remaining characters can contain any combination of upper/lower case letters, numbers and symbols.

Question by:mdtanner
    LVL 4

    Accepted Solution


    Try the following regex


    This will check the follwoing conditions

    Character length: 7 (won't check the max length as 30 - put the maxlength of the textbox to 30)
    Must contain at least one number.
    Must contain at least one symbol/special character- (])(?=.*[@#$%^&+=] are the included special characters)

    LVL 20

    Expert Comment


    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now