regex to match a word with unique (non-repeating) characters

Try this, it might work,

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

Explanation

Assert position at the beginning of a line (at beginning of the string or after a line break character) «^»
Match the regular expression below «(?:([A-Z])(?!.*\1))*»
   Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
   Match the regular expression below and capture its match into backreference number 1 «([A-Z])»
      Match a single character in the range between “A” and “Z” «[A-Z]»
   Assert that it is impossible to match the regex below starting at this position (negative lookahead) «(?!.*\1)»
      Match any single character that is not a line break character «.*»
         Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
      Match the same text as most recently matched by capturing group number 1 «\1»
Assert position at the end of a line (at the end of the string or before a line break character) «$»

Leave a Comment