How does the regex spot the repeating letters exactly?
Allow str = “hello”.
function isIsogram2(str){
return !/(\w).*\1/i.test(str)
}
How does the regex spot the repeating letters exactly?
Allow str = “hello”.
function isIsogram2(str){
return !/(\w).*\1/i.test(str)
}
Mh…as far as i can tell, that function will works as follow:
First of all the regex will match an alphanumeric char, followed by any number of characters, followed again by the the same alphanumeric char matched the first time.
Then test if the pattern exists in the word, and return the opposite (so it returns true if there is no match)^^