in reply to REgular expression to check the string that allows "a","b" and "c" to occur only once in any order.
(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.)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"} }
|
|---|
| 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 |