%% Return Indices in Cell Array
% Find the occurrences of a substring in a character vector. Force strfind to return the indices of those occurrences in a cell array. Then display the indices.
% Create a character vector and find the occurrences of the pattern ain.

str = 'The rain in Spain.';
k = strfind(str,'ain','ForceCellOutput',true)

%
% strfind returns a scalar cell that contains a numeric array, which contains indices of occurrences of the substring ain in str. To access the numeric array within the cell, use curly braces.

k{1}

% Copyright 2012-2020 The MathWorks, Inc.