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 9214817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:03:29+00:00 2026-06-18T02:03:29+00:00

I have to create a Regex for password validation which match eg. abcdABCD1234$%^ password

  • 0

I have to create a Regex for password validation which match

eg.

abcdABCD1234$%^

password must contains atleast two lowercase,two uppercase, two numeric and two special character. But they can give more than this criteria

Note- pattern should be inorder.

String pattern="(?=.*[a-z]{2,})(?=.*[A-Z]{2,})(?=.*[0-9]{2,})(?=.*[@#$%&]{2,})";

it is working for me but it is not checking order
means
AB uppercase or anycharacter should not come before ab (lowercase).

Does it clear for u.

     String minNum="4";
     String max="20";

     String REGEX="(^(?!.*(d))(?=.*[a-z]{3,})(?=.*[A-Z]{2,})(?=.*[0-9]{3,})(?=.[@#$%&*><?+]{2,})^(?!.*(#r)).{"+minNum+","+max+"})";
     //String regex="(?=.*[a-z]{2,})(?=.*[A-Z]{2,})(?=.*[0-9]{2,})(?=.*[@#$%&]{2,})";

      String INPUT ="acABC1333323@#";

   Pattern p = Pattern.compile(REGEX);

   Matcher m = p.matcher(INPUT);

   System.out.println(m.matches());

it is working correctly but when i am changing password
“ABac1333323@#”; it also matches but it is in correct according to my requirement, because AB is first order.

  • 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-18T02:03:30+00:00Added an answer on June 18, 2026 at 2:03 am

    I think this is what you want

    (?=[a-z]{2,}).{2,}(?=[A-Z]{2,}).{2,}(?=\d{2,}).{2,}(?=[@#$%&]{2,}).{2,}
    

    It matches abcdABCD1234$%^ and abABcdCD1234$%^

    It does not match ABababcdCD1234$%^ or ABac1333323@#

    For two or more lower case followed by two or more upper case followed by two or more digits followed by two or more special characters, use :

    [a-z]{2,}[A-Z]{2,}\d{2,}[@#$%&]{2,}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string on which I try to create a regex mask that
I have to create regex to match ugly abbreviations and numbers. These can be
Hello I want to create a regex to find words which have capital words
My knowledge of regex is very weak. So far I have manage to create
I have create a vcf file that contains contacts by using this code ContentResolver
I need to create a regex expression for the following scenario. It can have
I'd like to create a RegEx Pattern statically, but I think I have the
I am trying to create a regex that will match the first 3 characters
Say I have a regex that checks for alphanumeric. I now want to create
I am working on a requirement wherein I have to create a strong password.

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.