|
hi,
i'd like to know how to get the number of regexp matches a pattern returns
ex: if I have $_ = "fooFOObarBAR";$_ =~ /[a-z]/
it would return 6
thx
cvv3@yahoo.com
|
|
|
my @instances = map { /[a-z]/g } "fooFOObarBAR";
my $instance_quantity = $#instances+1;
|
|
|
there are a lot of ways to do 1 think in perl, here is the way i would do it.
my $count = "fooFOObarBAR" =~ tr/[a-z]//;
print $count;
|
|
|
|
|
|
|
|
|
// |