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

This isn't a regex, but I don't think anyone mentioned it.
my @letters = qw(abc cba cab bab blab); for (@letters) { if(join('', sort split //, $_) eq "abc") {print "$_ matched\n"} else {print "$_ didn't match\n"} }
(My initial thought was to add up the ord() values of the characters. That would work too, but wouldn't be as concise since there isn't a reduce operator in Perl 5.)
  • Comment on Re: 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^2: REgular expression to check the string that allows "a","b" and "c" to occur only once in any order.
by parv (Parson) on Dec 12, 2007 at 20:42 UTC

    That is simple!

    A problem might arise if the desired letters could be part of a bigger string. Lacking any comments by isha on the specification :( so far, your solution is just as good.