Regular expressions that match 5 to 10 non repeating digits

Time:2020-11-24

For repeated 5 to 10 digit numbers, you can use a regular pattern such as {5,10}

No repetition of 5 to 10 digits, I think about it, not yet, but I have to check the Internet.

There was a good version, but regexbuddy passed the test anyway.

Copy codeThe code is as follows:
^(?!\d*?(\d)\d*?\1)\d{5,10}$

For (?!…) (…… )……… \1) I haven’t studied this form thoroughly. I really need to study it carefully when I have time.

The previous example of PHP:

Copy codeThe code is as follows:
<?php
$str = ‘123456789’;
$search = ‘/^(?!\d*?(\d)\d*?\1)\d{5,10}$/’;
$result = preg_match($search,$str);

Echo ‘matches 5 to 10 digits without repetition < br / >’;
if($result>0) {
Echo ‘consistent’;
}else {
Echo ‘does not conform’;
}
?>