Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.1.0 - Français


strcmp

compare character strings

Syntax

res = strcmp(string_one, string_two)
res = strcmp(string_one, string_two, "i")

Arguments

string_one

a character string or matrix of character strings.

string_two

a character string or matrix of character strings.

'i'

optional parameter to compare strings in a case-independent way. Default value is 's'.

res

a matrix of integers.

Description

res = strcmp(string_one, string_two) (or res = strcmp(string_one, string_two, 's')) returns an integral value indicating the relationship between the strings.

The value greater than zero indicates that the first character that does not match has a greater value in string_one than in string_two and the value less than zero indicates the opposite (lexicographical order).

The value equal zero indicates that string_one and string_two are equal.

res = strcmp(string_one, string_two, 'i') returns 0 if string_one is equal to string_two (case independently) and 1 indicates the opposite.

Examples

TXT1 = ['scilab','SciLab';'Strcmp','STRcmp'];
TXT2 = ['ScIlAb','sciLab';'sTrCmP','StrCMP'];
strcmp(TXT1,TXT2)
strcmp(TXT1,'scilab')
strcmp(TXT1,'SciLab')
strcmp(TXT1,TXT2,'i')
strcmp(TXT1,TXT2,'s')

See also

Report an issue
<< strchr Chaînes de caractères strcspn >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon May 22 12:39:43 CEST 2023