Contains Operator
See Also: Constrain Command, Pos Function, Uppercase Function, Lowercase Function
Purpose
Returns true from an expression in which the value of the second string is contained within the value of the first string.
Syntax
( {host-string} contains {sub-string} )
Where {host-string} is the string being parsed, and {sub-string} is the string being searched for. Both {host-string} and {sub-string} can be either a literal or a string variable.
What It Does
When the value of {sub-string} is present in the value of {host-string}, a contains expression evaluates to 1 (true). When it is not present, it evaluates to 0 (false).
Example
string sTitle
if ((sTitle contains "engineer") OR (sTitle contains "manager")) ;
send DoCalcBonus
In this example, the procedure DoCalcBonus is called for any value of the string variable sTitle that contains either "engineer" or "manager".
Example
string sFruit
if (uppercase(sFruit) contains "APPLE") ;
send DoMakeCider
In this example, the procedure DoMakeCider is called whenever the value of the string variable sFruit is made up of the letters of "APPLE", regardless of their capitalization.
Notes
-
Containsdoes not support wildcard characters (*and?). It treats these characters only as literals. -
Containsdoes not return the position in{host-string}at which{sub-string}is found, nor the number of times it is present. Theposfunction may be used to determine the position of{sub-string}in{host-string}. -
Containsdoes not recognize a match between the upper and lower cases of the same letter. Theuppercaseorlowercasefunctions may be used to disable this behavior.