Find strings within other strings
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 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
,pat
,'ForceCellOutput',cellOutput
)strfind
to return k
as a cell array
when cellOutput
is true, even when str
is a
character vector.
If pat
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
| count
| endsWith
| extract
| matches
| pattern
| regexp
| replace
| split
| startsWith
| strcmp
| strtok