Skip to main content

Contains ([)

Tests whether the sequence of characters in the right operand is a substring of the left operand.

Details

The Contains operator tests whether the sequence of characters in the right operand is a substring of the left operand. If the left operand contains the character string represented by the right operand, the result is TRUE (1). If the left operand does not contain the character string represented by the right operand, the result is FALSE (0). If the right operand is the null string, the result is always TRUE.

Examples

The following example tests whether L contains S. Because L does contain S, the result is TRUE (1).

 SET L="Steam Locomotive",S="Steam"
 WRITE L[S

The following example tests whether P contains S. Because the character sequence in the strings is different (a period in P and an exclamation point in S), the result is FALSE (0).

 SET P="Let's play.",S="Let's play!"
 WRITE P[S
FeedbackOpens in a new tab