String.icontains("pattern")

Tinderbox Icon


Operator Type:   Function
Operator Scope of Action:   Item
Operator Purpose:   Boolean (query)

String.icontains("pattern")

New to v5.7.1, this operator tests whether pattern matches the target string attribute or matches a whole discrete value string within a the target list/set attribute value. Matches are always case-insensitive, unlike String/List.contains(). The match gives a Boolean result.

pattern is one of:

$MyString.icontains("pattern") 

For example:

$MyString.icontains(pattern)

is true if $MyString matches pattern. This is the equivalent to the older form of AttributeName(pattern) which is now 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:

$MyString.icontains($MyMatchText) 

$MyString.icontains($MyString(agent)) 

$MyString(parent).icontains("Tuesday") 

"Any day like Saturday is good".icontains($MyDay) 

"Any day like Saturday is good".icontains("Saturday") 

From v5.10.2, if the regular expression pattern is found the function now 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 postion 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:

!$MyString.icontains("Tuesday") 


Possible relevant notes (via "Similar Notes" feature):

Up: Full Operator List
Previous: String.empty  Next: String.json() 

A Tinderbox Reference File : Actions & Rules : Operators : Full Operator List : String.icontains("pattern")

Quicklinks: Attributes | Action Codes | Export Codes | Designators | Date Formats | aTbRef Site Map

[Last updated: 16 May 2012, using v5.11.1]


Search:

Google search aTbRef for:  


Creative Commons Licence

aTbRef by Mark Anderson is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

[See aTbRef CC licence Attribution & Waiver info]

Made with Tinderbox