Operator Scope of Action:
Operator First Added:
This operator tests whether pattern matches the referenced string attribute or matches a whole discrete value string within a the referenced list/set attribute value. Matches are always case-insensitive, unlike String/List.contains(). The match gives a Boolean result.
pattern is one of:
- an action code expression (which includes just referencing a single attribute name')
- a quoted literal string (i.e. actual text). Important: do not omit the enclosing quotes. If omitted, Tinderbox will try to evaluate the string as an expression. Doing this may result in the expected result but this is actually a false positive. So, remember to enclose your literals in quotes.
N.B. Unlike with String-type attributes, regex cannot be used.
The contains operator may also be used with both sets and lists, in which case it tests for set membership, i.e. matching to complete individual values rather than part of values. Thus:
is true if $MyList is "Monday;Tuesday;Friday". Other examples:
The left-hand argument may also be a literal list:
If the regular expression pattern is found the function returns the match offset+1, where offset is the distance from the start of the string to the start of the matched pattern. Formerly, .icontains() returned true if the pattern was found. The '+1' modifier ensures that a match at position zero return a number higher than zero which would otherwise coerce to false. Since 1+offset is always true, no changes are required in existing documents but the function also now gives usable offset information.
Testing "does not contain"
Use a ! prefix to the query argument:
Use of parentheses after the !, around the query, can assist Tinderbox's parsing:
Dealing with inline quote characters