重复单词检测

An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an isogram. Ignore letter case.

  function isIsogram(str){
  return !/(\w).*\1/i.test(str);
}

/(\w).*\1/i 这个可以理解为 a******a
\1 就是匹配第二次

你可能感兴趣的:(重复单词检测)