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.
CharacterCounts[{"string1","string2",…},…]
gives the counts for each of the stringi.
Details and Options
- CharacterCounts[string,n] counts n-grams that start at every position in string.
- CharacterCounts has the option IgnoreCase. With the setting IgnoreCaseTrue, characters are in effect all converted to lower case before being counted.
- CharacterCounts[BioSequence["type","seq"]] will give the characters of the string "seq".
Examples
open allclose allBasic Examples (3)
Scope (3)
Options (2)
IgnoreCase (2)
The default setting IgnoreCase->False counts uppercase and lowercase characters independently:
Use IgnoreCase->True to count all occurrences of a letter, regardless of case:
Applications (1)
Properties & Relations (1)
CharacterCounts counts the distinct characters in a string, including numbers, punctuation and whitespace:
LetterCounts includes only the letter characters:
Text
Wolfram Research (2015), CharacterCounts, Wolfram Language function, https://reference.wolfram.com/language/ref/CharacterCounts.html (updated 2024).
CMS
Wolfram Language. 2015. "CharacterCounts." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/CharacterCounts.html.
APA
Wolfram Language. (2015). CharacterCounts. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CharacterCounts.html