Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
^(?=[1-9]+([1-9])$)(?!.*(?!\1)(\d).*\2)(?:(?!\1)\d)*\1(?:(?!\1)\d)*\1$
/
gm
Input 1
New
123456782 -> true, last digit (2) occur twice (EXACTLY), no other repeated digits 189765432 -> false, last digit not repeated previously, only unique digits in it 123456889 -> false, not the last digit repeated 123476782 -> false, not only the last digit repeated 123426282 -> false, last digit repeated more than twice.
Extraction
123456782 -> true, last digit (2) occur twice (EXACTLY), no other repeated digits 189765432 -> false, last digit not repeated previously, only unique digits in it 123456889 -> false, not the last digit repeated 123476782 -> false, not only the last digit repeated 123426282 -> false, last digit repeated more than twice.