in reply to Re^2: REgular expression to check the string that allows "a","b" and "c" to occur only once in any order. (permutations)
in thread REgular expression to check the string that allows "a","b" and "c" to occur only once in any order.

True. The OP's spec wasn't clear as to whether or not the strings could contain other characters (or were limited to only those in the specified character set), or if a, b, and c were really characters and not stand-ins for longer strings. I went with Occam's razor and took the OP literally. (Update: Since the list of invalid strings contained only a, b, and c; I assumed if other characters were possible there would be an example of it in the invalid list. ikegami is right, though - this was probably more of an assumption than I first thought.)

This approach could also be problematic if the character set is large and/or if the wanted strings were significantly longer, since the number of permutations would rapidly increase. In that case, a RE-based approach may be better.

Nonetheless, thanks for providing a more robust solution.

  • Comment on Re^3: REgular expression to check the string that allows "a","b" and "c" to occur only once in any order. (permutations)

Replies are listed 'Best First'.
Re^4: REgular expression to check the string that allows "a","b" and "c" to occur only once in any order. (permutations)
by ikegami (Patriarch) on Dec 11, 2007 at 07:03 UTC

    I went with Occam's razor and took the OP literally.

    No, that's what I did. You added the clause "and no characters other than a, b and c".

    It could very well be the OP wants what you provided, but it's not a literal interpretation of the OP.

    The authors of the other two (working) solutions didn't add that clause.