Main Content

strncmpi

Compare first N characters of strings (case insensitive)

Description

example

tf = strncmpi(str1,str2,n) compares up to n characters of str1 and str2, ignoring case. The operator returns 1 (true) if the strings are identical and 0 (false) otherwise. Use this operator in the Requirements Table block.

Examples

expand all

In a Requirements Table block, create a requirement that checks if the string "Hello, world!" matches the first thirteen characters of the string "hello, World!!!!!!!!!!!!", ignoring case.

y = strncmpi("Hello, world!","hello, World!!!!!!!!!!!!",13)

This example shows a requirement that checks if the string "Hello, world!" matches the first thirteen characters of the string "hello, World!!!!!!!!!!!!", ignoring case.

Input Arguments

expand all

Input strings, specified as string scalars. Enclose literal string with double quotes.

Example: "Hello"

Data Types: string

Number of characters checked, starting at the beginning of each string, specified as a positive integer.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Limitations

  • This operator does not support the use of Simulink.Bus object fields.

Version History

Introduced in R2022b