Regex To Determine If A String Has All Unique Characters

A regular expression that determines if a given string has all unique (none repeating) characters. This is something needed when doing reports or analyses of what is in a string.

/^(?:([A-Za-z])(?!.*\1))*$/g

Matches:

  • abcde
  • com
  • net

Non-matches:

  • regex
  • pattern
  • aabbcc

See Also: