Created
September 1, 2017 03:20
-
-
Save alex-cory/5eb41a3fdda01b46b3a6bee8a71237f6 to your computer and use it in GitHub Desktop.
Tests if a string contains all unique characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode 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