count the number of occurrences of a character in a string - Maple Help

Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Miscellaneous Utilities : StringTools/CountCharacterOccurrences

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.

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)