Home > other >  Multiple regex condition
Multiple regex condition

Time:09-13

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

CodePudding user response:

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

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

DEMO

  • Related