endsWith()
The strLib.endsWith() system function is used to check if a string ends with a specified suffix. It returns “true” if the string ends with the suffix, “false” otherwise.
Syntax
strLib.endsWith(
target STRING | CHAR | DBCHAR | MBCHAR | UNICODE In,
suffix STRING | CHAR | DBCHAR | MBCHAR | UNICODE In)
returns (result BOOLEAN)
- target
-
Input can be any value that is assignment compatible with any of the above types.
- suffix
-
Input can be any value that is assignment compatible with any of the above types.
- result
-
It returns “true” if the targetends with the suffix, “false” otherwise.
Example
function main()
myString String = “Customer”;
suffixString String = “omer”;
myChar Char(8) = “Customer”;
suffixChar Char(3) = “om”;
myUni Unicode(8) = “Customer”;
suffixUni Unicode(3) = “omer”;
sysLib.writeStdout(“Does ‘Customer’ finish with ‘omer’? “ + strLib.endsWith(myString, suffixString));
sysLib.writeStdout(“Does ‘Customer’ finish with ‘om’? “ + strLib.endsWith(myChar, suffixChar));
sysLib.writeStdout(“Does ‘Customer finish with ‘omer’? “ + strLib.endsWith(myUni, suffixUni));
end
The output is as follows:
Does ‘Customer’ finish with ‘omer’? true
Does ‘Customer’ finish with ‘om’? false
Does ‘Customer’ finish with ‘omer’? true