CountCharacterOccurrences - Maple Help

StringTools

 CountCharacterOccurrences
 count the number of occurrences of a character in a string

 Calling Sequence CountCharacterOccurrences( s, ch )

Parameters

 s - Maple string ch - Maple string; character

Description

 • The CountCharacterOccurrences( s, ch ) calling sequence counts the number of occurrences of the character ch in the string s. A non-negative integer is returned.
 • All of the StringTools package commands treat strings as (null-terminated) sequences of $8$-bit (ASCII) characters.  Thus, there is no support for multibyte character encodings, such as unicode encodings.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{CountCharacterOccurrences}\left("abcde","a"\right)$
 ${1}$ (1)
 > $\mathrm{CountCharacterOccurrences}\left("abada","a"\right)$
 ${3}$ (2)
 > $\mathrm{CountCharacterOccurrences}\left("","a"\right)$
 ${0}$ (3)
 > $\mathrm{CountCharacterOccurrences}\left("xyz","a"\right)$
 ${0}$ (4)