Q: regex for duplicate number I am trying to check if a string does NOT have a number more than once.
Examples:
"1..3..156" should return false.
"23..45.2." should return false.
"1.3.456.." should return true.
"5...46.28" should return true.
I am hoping to use regex for this as that is what I need the most work in compared to filtering it out with loops. I was wondering if this is possible.
I have tried the regex /(\d)\1/ but this only gets a match if the numbers are back to back. I am trying to find a way to look ahead at rest of string as well. Any help will be much appreciated!

A: You may use the regex pattern (\d).*\1:


function hasNoDuplicateDigit(input) {
    return !/(\d).*\1/.test(input);
}

console.log("1..3..156 => " + hasNoDuplicateDigit("1..3..156"));
console.log("23..45.2 => " + hasNoDuplicateDigit("23..45.2"));
console.log("1.3.456.. => " + hasNoDuplicateDigit("1.3.456.."));
console.log("5...46.28 => " + hasNoDuplicateDigit("5...46.28"));


The pattern used here matches (and captures) any single digit which is followed by that same digit at a later point in the input.
