strfind
Find strings within other strings
Description
searches k = strfind(str,pat)str for occurrences of pat. The
output, k, indicates the starting index of each occurrence of
pat in str. If
pat is not found, then strfind returns
an empty array, []. The strfind function
executes a case-sensitive search.
If
stris a character vector or a string scalar, thenstrfindreturns a vector of typedouble.If
stris a cell array of character vectors or a string array, thenstrfindreturns a cell array of vectors of typedouble.
forces k = strfind(str,pat,'ForceCellOutput',cellOutput)strfind to return k as a cell array
when cellOutput is true, even when str is a
character vector.
Examples
Input Arguments
Output Arguments
Tips
If
patis a character vector or string scalar with no characters (''or""), thenstrfindreturns an empty array.The
containsfunction is recommended for finding patterns within string arrays.
Extended Capabilities
Version History
Introduced before R2006a