Perl Regular Expressions for Password Checking

Posted on 2009-04-29
Last Modified: 2012-05-06
OK... I admit it... I'm a "regular expression" ignoramus.  

I'm enforcing passwords of at least 6 characters in length, with at least 1 uppercase letter, 1 lowercase letter, and at least 1 number.  How do I construct a regular expression that checks that?
Question by:eDistrict
    LVL 19

    Accepted Solution

    Just chain togethor a regexp for each condition you need
    my $pwd = '12A45b';

    if ( $pwd =~ /\w{6,}/ and $pwd =~ /\d/ and $pwd =~ /[A-Z]/ and $pwd =~ /[a-z]/ )
        # password is valid
        #re enter password

    Author Closing Comment

    Thank you very much!  :)   I've GOT to break down and learn regexp's... :::sigh:::

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
    Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
    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…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    760 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

    14 Experts available now in Live!

    Get 1:1 Help Now