contains

Syntax expression1 contains expression2

Action Evaluates both expressions as strings, and determines whether the result of expression1 contains the result of expression2. If expression1 produces a list or record, expression2 is evaluated as a list or record and the comparison is done on that basis

rather than as strings.

Examples "The quick brown fox" contains "quick"

   » true

string.dateString () contains "Fri"

   » true

Thank God it's Friday!

1234 contains 23

   » true

The numbers are converted to strings for this operation.

{1, 2, 3, 4} contains 3

   » true

The number 3 is converted to a list, and the comparison results in true.

{1, 2, 3, 4} contains {2, 4}

   » false

The first list contains the numbers 2 and 4, but not the list {2, 4} in sequence.

{"smoke": true, "fire": false, "heat": true\} contains \{"fire": false, "smoke": true}

   » true

See Notes.

Notes The contains operator is case-sensitive; upper-case characters do not match lower-case ones.

When applied to record values, the contains operator is not order-sensitive. It results in a true value as long as each item in the second record is contained in the first record and has the same value.

See Also beginsWith

endsWith

string.patternMatch

Discuss