Not sure if this is the best way to express this, so I’ll just give an example. Say I have characters a,b,c,d. I want to accept any string that has 0 or 1 of each character in any order. Lines such as "ab" "abcd" "dcab"would be acceptable. Is it possible to do this only with regular expressions?
The only thing I came up with is this ((a|b|c|d){0,1}){0,4}. However, this would not work, since it would accept strings such as "aaaa".
source
share