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

This looks like overkill.

If a string is required to contain all of an "a", a "b" and a "c" and its length is limited to 3, then it can only contain one of each.

So this ought to suffice:

/^(?=.*a)(?=.*b)(?=.*c).{3}\z/

Of course, yours is the way to go if the length is not limited to 3.

  • Comment on Re^2: REgular expression to check the string that allows "a","b" and "c" to occur only once in any order.
  • Download Code

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