Skip to content

Instantly share code, notes, and snippets.

@alex-cory
Created September 1, 2017 03:20
Show Gist options
  • Save alex-cory/5eb41a3fdda01b46b3a6bee8a71237f6 to your computer and use it in GitHub Desktop.
Save alex-cory/5eb41a3fdda01b46b3a6bee8a71237f6 to your computer and use it in GitHub Desktop.
Tests if a string contains all unique characters
// does not include special chars
const isUnique = str => !/([a-z0-9]).*?\1/i.test(str)
// includes special chars
const isUnique = str => !/^.*(.).*\1.*$/i.test(str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment