Core Function SubStrCmp
From Sputnik Wiki
SubStrCmp( <main_str>, <str>, <offset>, <length>, <ignoreCase> )
Contents |
Description
Comparison of two strings from an offset, up to length characters.
Parameters
main_str
The main string being compared.
str
The secondary string being compared.
offset
Optional; The start position for the comparison. If negative, it starts counting from the end of the string.
Default: 0
length
Optional; The length of the comparison.
Default: the maximal possible length
ignoreCase
Optional; The flag to set the case.
true = Case insensitive false = Case sensitive (Default)
Return Value
Returns < 0 if main_str from position offset is less than str. OR > 0 if it is greater than str OR 0 if they are equal.
If offset is equal to or greater than the length of main_str or length is set and is less than 1, SubStrCmp() returns NULL.
Remarks
None.
Example
say SubstrCmp("abcde", "bc", 1, 2); // 0 say SubstrCmp("abcde", "de", -2, 2); // 0 say SubstrCmp("abcde", "bcg", 1, 2); // 0 say SubstrCmp("abcde", "BC", 1, 2, true); // 0 say SubstrCmp("abcde", "bc", 1, 3); // 1 say SubstrCmp("abcde", "cd", 1, 2); // -1 say SubstrCmp("abcde", "abc", 5, 1); // NULL (Nothing will print)