which can be condensed asuse strict; use warnings; my $str=""; for $str('aaa'..'ccc') { if($str=~m/^[abc]{3}$/) { if($str!~m/(.*a.*a)/) { if($str!~m/(.*b.*b)/) { if($str!~m/(.*c.*c)/) { print "\' $str \' is a Match\n"; } else { print "The string $str contains duplicated 'c'\n"; } } else { print "The string $str contains duplicated 'b'\n"; } } else { print "The string $str contains duplicated 'a'\n"; } } else { print "Either the string \'$str\' contains a character not bel +onging to the class [abc] or is more than 3 characters\n"; } }
use strict; use warnings; my $str=""; for $str('aaa'..'ccc') { if($str=~m/^[abc]{3}$/ && $str!~m/(.*a.*a)/ && $str !~ m/(.*b.*b)/ + && $str!~ m/(.*c.*c)/) { print "\' $str \' is a 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 narainhere
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: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |