I have a string that contains 4 digits. I need to check whether this string has no more than 1 repeated digit.
==============================================================================================================

**This group should be matched:**

> 
> 
> ```
> 1234  match    // no repeated digits
> 1123  match    // only one repeated digit 1
> 1213  match
> 1231  match
> 1223  match
> 1233  match
> 
> ```
> 
> 

**This group should not be matched:**

```
1222  fail   //digit 2 repeated 3 times
2222  fail
1112  fail
1211  fail
1212  fail   // digits 1 and 2 repeated 2 times
1122  fail
1221  fail

```

**I tried these 2 regex, but they don't work correctly**

* > 
> ^(?:(\d)(?!(.).\*\2)){4}$
> 
> 
>
* > 
> ^(?:(\d)(?!.\*\1{2}))(?:(\d)(?!.\2)){3}$
> 
> 
>

**Here are my links:**

* <https://regex101.com/r/34FExf/1>
* <https://regex101.com/r/vTIdAD/1>