On 29 May 2022 21:47 -0700, from bakul(a)iitbombay.org (Bakul Shah):
You can write a program to generate all permutations
and use that as your regexp.
For example abc maps to abc|acb|bac|bca|cab|cba. You can rearrange it as
a(bc|cb)|b(ac|ca)|c(ab|ba) to see how an n letter permutation is computed from
permutations of n-1 letters. I don’t think you can do better.
I was trying to do something very similar using procmail regexes some
time ago, only with strings instead of individual characters (for
parsing and matching on arbitrarily-ordered, comma-separated values
within a header). I never did come up with a good solution.
--
Michael Kjörling •
https://michael.kjorling.se • michael(a)kjorling.se
“Remember when, on the Internet, nobody cared that you were a dog?”