Match the alphanumeric words(NOT NUMERIC-ONLY words) which have unique digits

You can use

\b(?=\d*[a-z])(?=[a-z]*\d)(?:[a-z]|(\d)(?!\w*\1))+\b

https://regex101.com/r/TimjdW/3

Anchor the start and end of the pattern at word boundaries with \b, then:

  • (?=\d*[a-z]) - Lookahead for an alphabetical character somewhere in the word
  • (?=[a-z]*\d) - Lookahead for a digit somewhere in the word
  • (?:[a-z]|(\d)(?!\w*\1))+ Repeatedly match either:
    • [a-z] - Any alphabetical character, or
    • (\d)(?!\w*\1) - A digit which does not occur again in the same word

Here is a bit shorter & faster regex to make it happen since it doesn't assert negative lookahead for each character:

/\b(?=[a-z]*\d)(?=\d*[a-z])(?!\w*(\d)\w*\1)[a-z\d]+\b/ig

RegEx Demo

RegEx Details:

  • \b: Word boundary
  • (?=[a-z]*\d): Make sure we have at least a digit
  • (?=\d*[a-z]): Make sure we have at least a letter
  • (?!\w*(\d)\w*\1): Make sure digits are not repeated anywhere in the word
  • [a-z\d]+: Match 1+ alphanumericals
  • \b: Word boundary

You could assert all the conditions using one negative lookahead:

\b(?![a-z]+\b|\d+\b|\w*(\d)\w*\1)[a-z\d]+\b

See live demo here

The important parts are starting match from \b and immediately looking for the conditions:

  • [a-z]+\b Only alphabetic

  • \d+\b Only numeric

  • \w*(\d)\w*\1 Has a repeating digit