"Dung Ping" <du*******@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Such as:
JavaScript can do this pretty easily (really any language that can navigate
a string and has the concept of a hash table or the like can do it easily).
Conversationally this might be:
+) Create a hash table (new Array()) to store the counts. The keys of this
array will be the characters in question.
+) Start looping from the first to last character of the string. Use the
String.length property to get the length and the String.charAt() method to
get the current character.
+) For each character see if there's already a hash-table entry for the
character. If there IS increment the value and move on. If there ISN'T
create an entry for the character and populate it's value with 1 (one).
+) Output your hash table in whatever format you like.
If this isn't clear let me know and I'll try to work up some code.
How you get the source string into the script might be a matter for
discussion (if you want the current script string you'd have to grab the
source from the DOM - but how you'd differentiate different scripts and such
is really something you'd have to answer).
Jim Davis