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.
"A((B?C?)|(C?B?))|B((A?C?)|(C?A?))|C((A?B?)|(B?A?))"
It is A|B|C and each of them can be followed by an pair of optional values
A(B?C?) matches A, AB,AC and ABC
A(C?B?) matches A, AC,AB and ACB
but not ACAC, AA or ACC. The cases with B or C as first character are equivalent.
For longer Strings, this will get ugly soon. A better approach would be (pseudocode):
string.sort().matches ("^A?B?C?$") && string.length > 0