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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:58:42+00:00 2026-05-22T00:58:42+00:00

Here is my @Pattern annotation. I want to disallow digits that repeat 9 times.

  • 0

Here is my @Pattern annotation. I want to disallow digits that repeat 9 times. What have I done wrong?

@Pattern(regexp="(?!.*\\d{9})")

These would be invalid strings:

111111111
222222222

These would be valid:

111111112
222222221
123456789

Only strings with a length of 9 will be valid but this is not needed as part of the regular expression since that will be controlled by other annotations.

  • 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-22T00:58:43+00:00Added an answer on May 22, 2026 at 12:58 am

    Edited following the comments

    I think you meant you don’t want the same digit repeating 9 times. To do that, you need to capture one digit, and refer to that and see if it repeats for 8 more times.

    @Pattern(regexp="^(?!(\\d)\\1{8})")
    

    If you simply use \\d{9}, it will mean repeatition of any digits.

    Note also that you don’t need .*. Regex will decide where to start the match on its own.

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

Sidebar

Related Questions

I may have the wrong pattern here, but I think it's a fair topic.
I'm struggling for a pattern here. I have quite a few tasks that need
Here is the issue I am having: I have a large query that needs
I got just a test pattern here, but it does disallow spaces. $myarray[]='s s';
I've coded that in python but the language doesn't matter here: pattern = re.compile(^params:([0-9]+)$)
I'm trying to introduce dependency injection (DI) as a pattern here at work and
I've implemented the attached command behavior pattern found here and it works well to
The singleton is explained here: http://en.wikipedia.org/wiki/Singleton_pattern#PHP_5 . I want to use the singleton class
:vimgrep looks like a really useful thing. Here's how to use it: :vim[grep][!] /{pattern}/[g][j]
Here's the scenario. I'm using a url rewriter that allows me to specify patterns

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.