MATLAB Function Reference |

Compare first n characters of strings ignoring case

**Syntax**

**Description**

`strncmpi('`

returns 1 if the first `str1`

,'*'*`str2`

,n)
*'*`n`

characters of the strings

and *str1*

are the same except for case, and 0 otherwise.*str2*

```
TF = strncmpi(S,T,n)
```

when either `S`

or `T`

is a cell array of strings, returns an array the same size as `S`

and `T`

containing 1 for those elements of `S`

and `T`

that match except for case (up to `n`

characters), and 0 otherwise. `S`

and `T`

must be the same size (or one can be a scalar cell). Either one can also be a character array with the right number of rows.

**Remarks**

`strncmpi`

is intended for comparison of character data. When used to compare numeric data, `strncmpi`

returns `0`

.

`strncmpi`

supports international character sets.

**See Also**

`strncmp`

, `strcmpi`

, `strcmp`

, `strmatch`

, `strfind`

, `findstr`

, `regexp`

, `regexp`

i, `regexprep`

strncmp | strread |