PDA

View Full Version : Occurence of character in string



asylu3
16-09-2004, 04:56 AM
Code:

$str=" I am a dog in a black house";
@count=$str=~m/a/g;
print "Total Occurence of 'a' :",scalar(@count);



Output:

Total Occurence of 'a' : 4