Tinderbox v10 Icon

String Attributes - comparison operators & case sensitivity

Comparison Operators

The comparison operators available are <, <=, ==, !=, >=, and >. The == and != operators always work as a case-sensitive comparison. Examples:

$Name > $AttribName 

$AttribName > $AttribName(path) 

$Created > $Created(parent) 

$Name < $Text  

$BorderColor == $Color 

For case-sensitive matches, use String.contains("regex"), e.g. $MyString.contains("dog"), where the regex is a string literal or regular expression. Using String.icontains("regex") forces a case-insensitive match. The same applies to Lists and Sets, see also Querying Lists and Sets.

Regex matches (via both old and new style contains) are case-sensitive by default, but when used in the context of an agent this can be modified. This is done by setting the agent's $AgentCaseSensistive attribute to false.

Thus, a case-insensitive 'dog' regex could match all case variants of 'dog' (dog, Dog, DOG, etc.). However, as this would also match a value of 'big dog', the degree of match of the regex can be restricted further by regular expression string delimiters, e.g. $MyString.contains("^dog$"). The caret (^) forces matching to start at the beginning of the string; note that it has to be doubled so as to escape it for Tinderbox, i.e. tell the program the symbol is not, in this context, export mark-up code. Similarly, the $ forces the match to run all the way to the end of a value string. This therefore excludes longer strings that might contain the word in question. The use of the $ in a regular expression should not be confused with the $AttributeName usage, which simply references an attribute's value.