Thanks to Kobi I just resolve the problem of checking all the permutations without repetition for a given string "abbc". This is the solution
(?:(?<A>a)|(?<B>b)|(?<C>c)){4}(?<-A>)(?<-B>){2}(?<-C>)
The expression has to have one "a", two "b" and one "c" in 4 consecutive characters.
Now I need something more complicated, I need to check a expression with 2 blocks of permutations:
- In the first 6 positions it has to find all the permutations of "abccc" but adding to each one a character in the 3rd position that can be any of them (a, b or c).
- In the second block it has to find all the permutations of "abccc"
I don't know if I have explained myself well, but:
- For the first 6 positions it has to have one a, one b, 3 c and in the 3rd position any value (a,b or c) no matter the order except for the 3rd position that can be any
- For the next 5 positions it has to have one a, one b and 3 c no matter the order.
I'm trying to explain it the best way possible. I'm sorry it looked like a copy-paste which is not.
The regex I'm looking for is "abXccc-abccc" where X could be a, b or c and the - separate the 2 blocks, although they are together I'm adding the - because for the first 6 characters I have to look for all the combinations and for the last 5 the same.
It doesn't have to be this way, it could be something similar, this is just an example. It could be "aabXXcc-abbc" for example.