Multiple regex condition

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

>Solution :

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

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

DEMO

Leave a Reply