strncmpi
Compares the first n characters of two texts, ignoring case.
Category: Language Fundamentals > Data Types
Syntax
tf = strncmpi(s1, s2, n)
Returns true if the first n characters match apart from case.
Description
strncmpi combines the prefix test of strncmp with the case insensitivity of strcmpi. It is often used to accept abbreviated option names, such as checking that the user typed at least the first three letters of 'normal'.
Texts shorter than n characters never match.
Input arguments
s1, s2- Character vectors, strings, cell arrays or string arrays.
n- Number of characters to compare.
Output arguments
tf- Logical scalar or array.
Example
Case-insensitive prefix
strncmpi('HELLO', 'help', 3)
strncmpi('HELLO', 'help', 4)
Output
ans = logical
1
ans = logical
0