I tried to check a number with regex, where only the last digit can occur twice.
Using javascript as programming language, tried many combinations on https://regex101.com/ but I was able do define only unique characters, like
(?:([1-9])(?!.*\1)){8}
but I am in trouble with the last one digit.
characterset: [1-9]
important : 0 is not in the characterset, therefore "\d" cannot work, only [1-9].
examples:
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.
Any help would be welcomed. How to apply a regex for it?