Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regex for 8 digits non repeating numbers

I want to make a regex for 8 digit non-repeating regex for phone number. It should not match with 11111111 or 22222222 …. 88888888

I tried to make a Regex but it only matches for 1

Example – ^(?!.*([0-9])1{7})[0-9]{8}$

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What corrections do I need in this?

>Solution :

Do this:

^(\d)(?!\1{7})\d{7}$

Capture the first digit and then ensure that it is not repeated 7 more times.

Demo

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading