Could also count using tr/// (wish I'd thought of that!).
>perl -wMstrict -le "for my $s (qw( AAA RR XXK AxA xAxxYxxRx A xAx ARKYGZX XxZxGxYxKxRxA AxAxAxA xYYYYx xRRRRRx RRRR )) { my $n = $s =~ tr{ARKYGZX}{}; printf qq{%s match : '%s' \n}, ($n == 2 || $n == 3) ? ' ' : 'NO', $s; } " match : 'AAA' match : 'RR' match : 'XXK' match : 'AxA' match : 'xAxxYxxRx' NO match : 'A' NO match : 'xAx' NO match : 'ARKYGZX' NO match : 'XxZxGxYxKxRxA' NO match : 'AxAxAxA' NO match : 'xYYYYx' NO match : 'xRRRRRx' NO match : 'RRRR'
In reply to Re^2: match a range of characters multiple times but they might scattered in the string
by AnomalousMonk
in thread match a range of characters multiple times but they might scattered in the string
by lrl1997
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |