compare

Compare two strings lexicographically

Information

This information is part of the Modelica Standard Library maintained by the Modelica Association.

Syntax

result = Strings.compare(string1, string2);
result = Strings.compare(string1, string2, caseSensitive=true);

Description

Compares two strings. If the optional argument caseSensitive=false, upper case letters are treated as if they would be lower case letters. The result of the comparison is returned as:

result = Modelica.Utilities.Types.Compare.Less     // string1 < string2
       = Modelica.Utilities.Types.Compare.Equal    // string1 = string2
       = Modelica.Utilities.Types.Compare.Greater  // string1 > string2

Comparison is with regards to lexicographical order, e.g., "a" < "b";

Syntax

result = compare(string1, string2, caseSensitive)

Inputs (3)

string1

Type: String

string2

Type: String

caseSensitive

Default Value: true

Type: Boolean

Description: = false, if case of letters is ignored

Outputs (1)

result

Type: Compare

Description: Result of comparison