Suppose I have the set of characters [ABC]
. I\'m looking for a regex that would match any permutation of the superset except the empty set, i.e.
This is not something that regular expressions are good at. You might just want to create a list of permutations instead, and then produce all unique substrings.
something like:
def matches(s, characters):
if len(s) != len(set(s)):
return False # not unique sequence of characters
return set(s).issubsetof(set(characters))