0

I have a regex wherein it doesn't accept 7 consecutive same numbers:

/^(?!.*([0-9])\1{6}).*/ 

If I want to add another validation to the above condition, where/how can I add this? i.e, I want to only accept numeric values and limit the maxLength to 15

1
  • It's.: /(\d{,15})/ Commented Sep 12, 2022 at 19:22

1 Answer 1

1

Change .* at the end to the pattern for the entire string.

/^(?!.*(\d)\1{6})\d{1,15}$/ 

DEMO

Sign up to request clarification or add additional context in comments.

3 Comments

Tried this one, but its failing 6 consecutive same numbers.
I can't reproduce that. I've added an online demo.
@PoulBak But \d{1,15} only matches numbers.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.