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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:57:02+00:00 2026-06-17T10:57:02+00:00

Can any one please explain the regex below, this has been used in my

  • 0

Can any one please explain the regex below, this has been used in my application for a very long time even before I joined, and I am very new to regex’s.

/^.*(?=.{6,10})(?=.*[a-zA-Z].*[a-zA-Z].*[a-zA-Z].*[a-zA-Z])(?=.*\d.*\d).*$/ 

As far as I understand

this regex will validate
– for a minimum of 6 chars to a maximum of 10 characters
– will escape the characters like ^ and $

also, my basic need is that I want a regex for a minimum of 6 characters with 1 character being a digit and the other one being a special character.

  • 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-17T10:57:04+00:00Added an answer on June 17, 2026 at 10:57 am
    ^.*(?=.{6,10})(?=.*[a-zA-Z].*[a-zA-Z].*[a-zA-Z].*[a-zA-Z])(?=.*\d.*\d).*$
    
    • ^ is called an “anchor”. It basically means that any following text must be immediately after the “start of the input”. So ^B would match “B” but not “AB” because in the second “B” is not the first character.

    • .* matches 0 or more characters – any character except a newline (by default). This is what’s known as a greedy quantifier – the regex engine will match (“consume”) all of the characters to the end of the input (or the end of the line) and then work backwards for the rest of the expression (it “gives up” characters only when it must). In a regex, once a character is “matched” no other part of the expression can “match” it again (except for zero-width lookarounds, which is coming next).

    • (?=.{6,10}) is a lookahead anchor and it matches a position in the input. It finds a place in the input where there are 6 to 10 characters following, but it does not “consume” those characters, meaning that the following expressions are free to match them.

    • (?=.*[a-zA-Z].*[a-zA-Z].*[a-zA-Z].*[a-zA-Z]) is another lookahead anchor. It matches a position in the input where the following text contains four letters ([a-zA-Z] matches one lowercase or uppercase letter), but any number of other characters (including zero characters) may be between them. For example: “++a5b—C@D” would match. Again, being an anchor, it does not actually “consume” the matched characters – it only finds a position in the text where the following characters match the expression.

    • (?=.*\d.*\d) Another lookahead. This matches a position where two numbers follow (with any number of other characters in between).

    • .* Already covered this one.

    • $ This is another kind of anchor that matches the end of the input (or the end of a line – the position just before a newline character). It says that the preceding expression must match characters at the end of the string. When ^ and $ are used together, it means that the entire input must be matched (not just part of it). So /bcd/ would match “abcde”, but /^bcd$/ would not match “abcde” because “a” and “e” could not be included in the match.

    NOTE

    This looks like a password validation regex. If it is, please note that it’s broken. The .* at the beginning and end will allow the password to be arbitrarily longer than 10 characters. It could also be rewritten to be a bit shorter. I believe the following will be an acceptable (and slightly more readable) substitute:

    ^(?=(.*[a-zA-Z]){4})(?=(.*\d){2}).{6,10}$
    

    Thanks to @nhahtdh for pointing out the correct way to implement the character length limit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can any one explain this? Overload resolution and partial ordering are used to select
can any one please explain why this gives different outputs? round(1.49999999999999) 1 round(1.4999999999999999) 2
Can any one please explain this: var js_var = 'hello'; $.ajax({ type: POST, url:
Can any one please explain the below simple statement @object ||= ::Tablename.where (:fieldname =>
What is server.MapPath() in asp.net. Can any one please explain with example written in
can you please any one explain AES/CBC/PKCS5Padding encryption and decryption using bounce castle i
Can any one explain class X x; what actually it mean ...in the program...Please
Can any one please explain me. What is the algorithm of garbage collector? How
can any one please explain me the basic important changes that are to be
I am developing my kernel in C++. So can any one please explain me

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.