strncmpi
Compare firstn
characters of strings (case insensitive)
Syntax
Description
compares up totf
= strncmpi(s1,s2
,n
)n
characters ofs1
ands2
, ignoring any differences in letter case. The function returns1
(true
) if the two are identical and0
(false
) otherwise. Text is considered identical if the content of each is the same up to the end or the firstn
characters, whichever comes first, ignoring case. The return resulttf
is of data typelogical
.
前两个输入参数可以是任何combination of string arrays, character vectors, and cell arrays of character vectors.
Examples
Input Arguments
Output Arguments
Tips
The
strncmpi
function is intended for comparison of text. If used on numeric arrays,strncmpi
always returns0
.For case-sensitive text comparison, use
strncmp
instead ofstrncmpi
.Although
strncmpi
与C共享名称function, it does not follow the C language convention of returning0
when the text inputs match.