Reputation: 422
I try write a regExp ==> unique character
Like that:
'mam' => false 2*m
'man' => true all unique
'lull' => false
PS. I want regExp, no function.
Upvotes: 0
Views: 457
Reputation:
I'd just test the string outright for true or false
function isNotDup(str) {
return str.match(/^(?:(.)(?!.*?\1))+$/) ? true : false;
}
console.log('mam = ' + isNotDup('mam'));
console.log('man = ' + isNotDup('man'));
console.log('lull = ' + isNotDup('lull'));
console.log('112233abcabccba = ' + isNotDup('112233abcabccba'));
Upvotes: 2