%% All Occurrences of Multiple Substrings
% Count the total number of occurrences of red and blue in a string array.
% Starting in R2017a, you can create strings using double quotes.

str = ["red green blue";
       "green red blue green blue"]

%
% count returns 2 for the first string because red and blue each occur once. count returns 3 for the second string because red occurs once and blue occurs twice.

A = count(str,["red","blue"])

% Copyright 2012-2020 The MathWorks, Inc.