Wolfram Language & System 10.3 (2015)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

CharacterCounts

CharacterCounts["string"]
gives an association whose keys are the distinct characters in string, and whose values give the number of times those characters appear in string.

CharacterCounts["string",n]
gives counts of the distinct n-grams consisting of runs of n characters in string.

Details and OptionsDetails and Options

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

Count the characters in a string:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=

Count the distinct 2-grams:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
Introduced in 2015
(10.1)