Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7825159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:51:08+00:00 2026-06-02T08:51:08+00:00

How can I construct a regular expression such that a password field I am

  • 0

How can I construct a regular expression such that a password field I am making contains at least one number, at least one lowercase letter and at least one uppercase letter where order DOES NOT matter and anything can be in-between these characters?

I have tried this and got something similar: ".*\\d.*[a-z].*[A-Z].*"
but that requires that the number comes first, the lowercase second and the uppercase last.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:51:11+00:00Added an answer on June 2, 2026 at 8:51 am

    Yours is not one of the use case regular expressions are particularly good at – if you’re stuck with regular expressions, I guess you have no choice but to enumerate the 6 cases:

    .*[0-9].*[a-z].*[A-Z].*|.*[0-9].*[A-Z].*[a-z].*|.*[a-z] ... | ...
    

    Check with actual java code would be easier (and more readable):

    String  password = "";
    boolean complies = password.matches(".*[0-9].*")
                    && password.matches(".*[a-z].*")
                    && password.matches(".*[A-Z].*");
    

    or (uglier, but possibly faster):

    boolean complies = false;
    {
        boolean hasDigit     = false;
        boolean hasLowercase = false;
        boolean hasUppercase = false;
        for (int i = 0; i < password.length(); i++) {
            char c = password.charAt(i);
            hasDigit     |= '0' <= c && c <= '9';
            hasLowercase |= 'a' <= c && c <= 'z';
            hasUppercase |= 'A' <= c && c <= 'Z';
            if (hasDigit && hasLowercase && hasUppercase) {
                complies = true;
                break;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to construct a regular expression that matches any letter (including accented
I'm trying to construct a regular expression that would match a pattern as such:
In python, I can construct my optparse instance such that it will automatically filter
I am trying to construct a regular expression that will match the following URL:
I'd like a JavaScript regular expression that can match a string either at the
Can somebody help me construct this regular expression, please... Given the following strings... "April
I'm trying to come up with a regular expression that can match only characters
How can I construct a query against an custom IUserType field in NHibernate? More
in my C# program, I have a regular expression textparser, that finds all occurrences
I'm looking for a regular expression that will match all strings EXCEPT those that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.