In what language are you talking about? You can use strlen in PHP or length in Perl.
Oh I read your post wrong I think. You're wanting to count how many times a certain character occurs in a string right? You can use substr_count in PHP and the tr/// function in perl for that.