Find strings within other strings
searches k
= strfind(str
,pattern
)str
for
occurrences of pattern
. The output, k
,
indicates the starting index of each occurrence of pattern
in str
.
If pattern
is not found, then strfind
returns
an empty array, []
. The strfind
function
executes a case-sensitive search.
If str
is a character vector
or a string scalar, then strfind
returns a vector
of type double
.
If str
is a cell array of character
vectors or a string array, then strfind
returns
a cell array of vectors of type double
.
forces k
= strfind(str
,pattern
,'ForceCellOutput',cellOutput
)strfind
to
return k
as a cell array when cellOutput
is
true, even when str
is a character vector.
If pattern
is a character vector
or string scalar with no characters (''
or ""
),
then strfind
returns an empty array.
Starting in R2016b, the contains
function
is recommended for finding patterns within string arrays.
contains
| regexp
| regexpi
| regexprep
| strcmp
| strcmpi
| strncmp
| strncmpi
| strrep
| strsplit
| strtok