
KevinR
Veteran

Mar 24, 2005, 4:26 PM
Post #2 of 3
(523 views)
|
|
Re: [abarabas] Counting a string
[In reply to]
|
Can't Post
|
|
you can count the number of characters in a string by using the length() function: $number = length($string); but that counts everything. If you only wanted to count letters, as in the alphabet (a-z) this will work: $count++ while $string =~ /[a-zA-Z]/g; I believe this also works and might be faster: $count = ($string =~ tr/a-zA-Z//); -------------------------------------------------
|