in reply to Re: Re: Fetching 3 letters only
in thread Fetching 3 letters only
If you only want the total
my $s = 'fileCapaber'; my $count = () = $s =~ m[(a|b|c)]gi; print $count; 4
but the tr/// solution above is easier and quicker.
If you want the individual counts, then you could try this.
print 'Found: ', scalar( () = $s =~ m/($_)/ig), "'${_}'s\n" for qw[a b + c] Found: 2 'a's Found: 1 'b's Found: 1 'c's
|
|---|