Operator Type:
Operator Scope of Action:
Operator Purpose:
Operator First Added:
Operator Altered:
Function [other Function type actions]
Item [operators of similar scope]
Data manipulation [other Data manipulation operators]
Baseline
String.countOccurrencesOf("string")
This function returns the Number of times that the literal 'string' appears in the String. If $MyString contains the word "aardvark", then:
$MyNumber = $MyString.countOccurrencesOf("a"); returns 3
$MyNumber = $MyString.countOccurrencesOf("aa"); returns 1
$MyNumber = $MyString.countOccurrencesOf("r"); returns 2
string is literal and must not be a regular expression. If the latter is needed use String.contains() or String.icontains().