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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:19:37+00:00 2026-05-27T22:19:37+00:00

I have a Java application where users must specify a PIN to log in.

  • 0

I have a Java application where users must specify a PIN to log in. When creating the PIN, there are only 3 requirements:

  • Must be 6 digits:

    \\d{6}
    
  • Must not have 4 or more sequential numbers:

    \\d*(0123|1234|2345|3456|4567|5678|6789)\\d*
    
  • Must not have a digit repeating 3 or more times (such as 000957 or 623334 or 514888):
    This is where I’m stuck…

I have tried:

\\d*(\\d)\\1{3}\\d*

but I believe the \1 is looking at the initial match to the \d* not the second match of (\d).


Answer used:
I have updated to using:

\\d{6}
(0123|1234|2345|3456|4567|5678|6789|9876|8765|7654|6543|5432|4321|3210)
\\d*?(\\d)\\1{2,}\\d*

To satisfy the initially stated requirements plus a few I hadn’t thought of! Thanks for all the help

  • 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-05-27T22:19:38+00:00Added an answer on May 27, 2026 at 10:19 pm

    Your regex is slightly off, since the first \d will match the first number. You only want to match 2 more after that.

    \\d*(\\d)\\1{2}\\d*
    

    should do the trick.

    Quick edit:
    If you want to match 2 or more numbers in sequence, just add a comma to your count, without specifying a maximum number:

    \\d*(\\d)\\1{2,}\\d*
    

    Or at least, this works in Perl. Let us know how you go.

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

Sidebar

Related Questions

I have an application written in Java that uses a jar file(it uses more
im creating a java application with netbeans. i have two jframes for login and
I have an Java application for copying large amounts of data from users' workstations
We have a java web service application that uses log4j to do logging. An
I have a Java application which I want to shutdown 'nicely' when the user
i have an Java J2ME application that does (at user request) create HttpConnections to
I have various Java Swing applications that are used by multiple users. My deployment
I am trying to write an application that uses java.net.Socket. I have also written
In our application, I have seen code written like this: User.java (User entity) public
I have a Java application that launches another java application. The launcher has a

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.