my $chars = "abc"; foreach (qw/abc bca cab cba bac acb aab abbc acc/) { my %seen; my $pat = $_; $pat =~ s/([\Q$chars\E])/++$seen{$1}/gex; if ((grep {$_ == 1} values %seen) == length($chars)) { print "$_ matches\n"; } else{ print "$_ doesn't match\n"; } }
In reply to Re: REgular expression to check the string that allows "a","b" and "c" to occur only once in any order.
by snoopy
in thread REgular expression to check the string that allows "a","b" and "c" to occur only once in any order.
by isha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |