in reply to REgular expression to check the string that allows "a","b" and "c" to occur only once in any order.
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"; } }
|
|---|
| 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 KurtSchwind (Chaplain) on Dec 11, 2007 at 05:43 UTC |