in reply to Match only certain characters?

It seems to me that you are asking for something as simple as this.

my @ss = ( 'A', 'B', 'C', 'AB', 'CA', 'ABC', 'xABCx', 'BxCxAx', ); for my $s (@ss) { if ($s =~ /A/ && $s =~ /B/ && $s =~ /C/) { print "$s\n"; } }

Which outputs:

ABC xABCx BxCxAx

EDIT: This response is only to the first part of the OP's question. That is:

...if you have the strings:

$a='ABCAAAABBBCCCCCAAABBBCCC';
$b='ASRGRTGRT89579843rrrrrr';

and you wanted to pick only the string that contains A, B and C (namely $a)...

Replies are listed 'Best First'.
Re^2: Match only certain characters?
by AnomalousMonk (Archbishop) on Nov 09, 2009 at 18:18 UTC
    But the OP asked for...
    ... a way to search only for the string that has the letters A,B,C and no other letter ...
    which clearly excludes a string like 'xABCx'.

      In that case, I'd have to do this, then.

      my @ss = qw( A B C AB CA ABC xABCx BxCxAx ); for (@ss) { if (/A/ && /B/ && /C/ && !/[^ABC]/) { print "$_\n"; } }