Main Content

strncmpi

Compare first n characters of strings (case insensitive)

Description

example

tf = strncmpi(s1,s2,n) compares up to n characters of s1 and s2, ignoring any differences in letter case. The function returns 1 (true) if the two are identical and 0 (false) otherwise. Text is considered identical if the content of each is the same up to the end or the first n characters, whichever comes first, ignoring case.

Note

The operator strncmpi is supported only in Stateflow® charts that use MATLAB® as the action language.

Examples

expand all

Return 1(true) if the two strings are identical, ignoring case.

h = "Hello, world!"
h2 = "Hello, world!!!!!!!!"
x = strncmp(h, h2, 8)
x2 = strncmpi(h, h2, 8)

Stateflow chart that uses the srtncmpi operator in a state.

Results from stateflow chart that uses the strncmpi operator in a state.

Limitations

Introduced in R2021b