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 string; quoted strings may be either:
- a literal string (i.e. actual text)
- a regular expression.
Important: do not omit the enclosing quotes for literal strings or regex. 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 regex or literals in quotes.
is true if $MyString matches pattern. This is the equivalent to the older form of AttributeName(pattern) which is deprecated. Apart from anything else, this newer syntax should remove the confusion over whether/when to use the $ prefix with attribute names in queries. Other more complex usage:
"Any day like Saturday is good".icontains($MyDay)
"Any day like Saturday is good".icontains("Saturday")
Getting the offset of the (first) pattern match
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. If there is more than one match, the offset of the first match is returned. Formerly, .contains() 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 gives usable offset information. Thus, if $MyString is "abcdefgehEi":
$MyNumber = $MyString.icontains("e"); returns
$MyNumber = $MyString.icontains("E"); returns
$MyNumber = $MyString.icontains("eh"); returns
Testing "does not contain"
Use a ! prefix to the query argument:
Use of parentheses after the !, around the query, can assist Tinderbox's parsing:
In an agent query or if() conditions the function can return back-references to matches of (sub-)strings.
String.icontains() clears the list of back references from previous processes, so $0 and $1 correspond to its own results, not those from prior expressions.
Dealing with inline quote characters