Skip to content

strcmp

Compare strings for equality (case-sensitive).

tf = strcmp(str1, str2)

Returns true when str1 and str2 are identical (including case), false otherwise. With cell-array inputs, compares element-wise.

strcmp('abc', 'abc') % 1
strcmp('abc', 'ABC') % 0
strcmp({'foo','bar'}, {'foo','baz'}) % [1 0]
  • strcmpi — Compare strings for equality (case-insensitive).
  • strncmp — Compare the first n characters of two strings (case-sensitive).
  • strncmpi — Compare the first n characters of two strings (case-insensitive).