Method Reference: string.count

string: out = count (str, pattern)
string: out = count (str, pattern, 'IgnoreCase', true)

Count occurences of pattern in string array.

out = count (str, pattern) returns a numerical array out of the same size as str containing the number of occurences of pattern in each corresponding element of str.

out = count (str, pattern, 'IgnoreCase', true) ignores case when identifying occurences of pattern.

Source Code: string

Example: 1

count returns how many times a substring occurs in each string.

 s = string ({'banana'; 'apple'})
s =
  2x1 string array

    "banana"    
    "apple"
 count (s, 'a')
ans =

   3
   1