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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:17:30+00:00 2026-06-02T17:17:30+00:00

Can I use \d\d\d\d[^\d] to check for four consecutive digits? For example, OK: 411112

  • 0

Can I use

\d\d\d\d[^\d]

to check for four consecutive digits?

For example,

OK:

  • 411112
  • 455553
  • 1200003
  • f44443
  • g55553
  • 3333

No:

  • f4442
  • 45553
  • f4444g4444
  • f44444444
  • 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-02T17:17:32+00:00Added an answer on June 2, 2026 at 5:17 pm

    If you want to find any series of 4 digits in a string /\d\d\d\d/ or /\d{4}/ will do. If you want to find a series of exactly 4 digits, use /[^\d]\d{4}[^\d]/. If the string should simply contain 4 consecutive digits use /^\d{4}$/.

    Edit: I think you want to find 4 of the same digits, you need a backreference for that. /(\d)\1{3}/ is probably what you’re looking for.

    Edit 2: /(^|(.)(?!\2))(\d)\3{3}(?!\3)/ will only match strings with exactly 4 of the same consecutive digits.

    The first group matches the start of the string or any character. Then there’s a negative look-ahead that uses the first group to ensure that the following characters don’t match the first character, if any. The third group matches any digit, which is then repeated 3 times with a backreference to group 3. Finally there’s a look-ahead that ensures that the following character doesn’t match the series of consecutive digits.

    This sort of stuff is difficult to do in javascript because you don’t have things like forward references and look-behind.

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

Sidebar

Related Questions

What Windows API function can I use to check to see if the current
I know that I can use the statement: [string1 rangeOfString:compareString].location!=NSNotFound to check if a
in Yii framework, can I use unique validation rule to check uniqueness of an
Does anyone how can I check whether the mailserver I use is down or
Can i use if else under a check constraint. Can i use check constraint
Is there a text I can use to check if a field is populated
Is there an api that I can use to check keywords (e.g. Amazon Kindle
What are the methods/tools i can use to check if in my application for
How can I use 'Check' statement to validate field value in mysql? look at
Hey Looking for a regular expression which I can use to check for valid

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.