CoderZone.org

Category: >> Perl Code >> Count specific characters in a string Bookmark and Share

<< lastnext >>

Snippet Name: Count specific characters in a string

Description: If you just need a count of characters in a string, use the built-in function length(). This snippet, however, will allow you to count only those characters in a particular range (like alphabet characters between a and z).

Also see:
» Count all words in a string
» Regexp: Find and highlight repeate...
» Convert entities into normal chara...
» Limit Text Area Characters
» Regular Expressions - REGEXP_SUBSTR
» Regular Expressions - REGEXP_LIKE
» Regular Expressions - REGEXP_REPLA...
» Regular Expressions - RegExp examp...
» Regular Expressions - RegExp examp...
» Regular Expressions - RegExp exam...
» Regular Expressions - Regexp Cheat...
» RegExp - Append first name first l...
» url_decode that respects utf8 char...
» Check number of characters in a ra...
» Binary RegExp select example
» Strip all non-alphanumeric charact...
» SELECT Example Using REGEXP

Comment: (none)

Author: CoderZone
Language: PERL
Highlight Mode: PERL
Last Modified: December 03rd, 2010

$str = "A sample string of regular text";
 
$count = $str =~ s/([a-z])/$1/gi;
 
print $count;
 
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 9