%% Find Pattern in Character Vector
% Find the starting indices for occurrences of patterns in a character vector.
% First, create a character vector.

str = 'Find the starting indices of a pattern in a character vector';

%
% Find the pattern in.

k = strfind(str,'in')

% There are four instances of the pattern in str.
%
% Find the pattern In.

k = strfind(str,'In')

% Since strfind is case sensitive, the pattern is not found. k is an empty array.
%
% Find the blank spaces in str.

k = strfind(str,' ')

% There are ten blank spaces in str.
% Copyright 2012 The MathWorks, Inc.