contains()
The strLib.contains() system function determines if a specific sequence of characters is present within a string. Returns “true” if the sequence of characters is found within the string. Otherwise, it returns “false”.
Syntax
strLib.contains(
target STRING | CHAR | DBCHAR | MBCHAR | UNICODE In,
sequence 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.
- sequence
-
Inputcan be any value that is assignment compatible with any of the above types.
- result
-
Returns“true” if the sequence is a substring of the target, “false” if it is not.
Example
function main()
myString String = “Customer”;
substring String = “sto”;
myChar Char(8) = “Customer”;
subChar Char(3) = ”abc”;
myUni Unicode(8) = “Customer”;
subUni Unicode(3) = “sto”;
sysLib.writeStdout(“Is ’sto’ contained in ‘Customer’? “ + strLib.contains(myString, substring));
sysLib.writeStdout(“Is ‘abc’ contained in ‘Customer’? “ + strLib.contains(myChar, subchar));
sysLib.writeStdout(“Is ‘sto’ contained in ‘Customer’? “ + strLib.contains(myUni, subUni));
end
The output is as follows:
‘sto’ is contained in ‘Customer’? true
‘abc’ is contained in ‘Customer’? false
‘sto’ is contained in ‘Customer’? true