... you wanted to pick only the string that contains A, B and C ...The question in the OP is not entirely clear; one can infer that at least one 'A' and 'B' and 'C' must all be present to match.
If that is so, this regex serves:
>perl -wMstrict -le "my $gotA = qr{ (?= .*? A) }xms; my $gotB = qr{ (?= .*? B) }xms; my $gotC = qr{ (?= .*? C) }xms; my $onlyABC = qr{ (?! .*? [^ABC]) }xms; for my $s (@ARGV) { my $match = $s =~ m{ \A $gotA $gotB $gotC $onlyABC }xms; print qq{'$s' }, $match ? 'matches' : 'no match'; } " "" A B C AB AC BC ABC CAB ABABCBCBCACA xABC ABCx xA xB xC Ax '' no match 'A' no match 'B' no match 'C' no match 'AB' no match 'AC' no match 'BC' no match 'ABC' matches 'CAB' matches 'ABABCBCBCACA' matches 'xABC' no match 'ABCx' no match 'xA' no match 'xB' no match 'xC' no match 'Ax' no match
In reply to Re: Match only certain characters?
by AnomalousMonk
in thread Match only certain characters?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |