For all methods listed here use the .contains() function (and sibling functions) instead.
Attribute values may be used as a target for queries:
- StringAttribute( data ). Gathers all notes whose StringAttribute contains the data string.
- StringAttribute( pattern ). Gathers all notes whose StringAttribute contains the pattern string. Patterns are regular expressions.
Whilst most easily understood in the context of string data, the target attribute need not always be specifically of String type. For instance, a File type attribute holds a path to a file - which is a string - and can thus be queries in the above fashion. Set-type and List-type attributes are collections of strings so can be pattern-matched, though only for whole value strings and not parts of individual value strings.
Note text can be searched too, as the Text attribute represents the note's body text.
IMPORTANT! Note that in this type of query, although an attribute name is used, a $ prefix is not used.
This is also a shorter AttributeName query method with not pattern supplied that gathers notes for which the boolean value of AttributeName (of any date type [sic]) evaluates to true. For numeric attributes, true is any value other than zero. For string attributes, true is any value other than "false" and the empty string. For date attributes, true is assumed to be a matching day. This query type may also be used in export templates. For example: ^any(children,Urgent)^ gathers all notes which have at least one child whose Urgent attribute resolves to true.
StringAttribute( data or pattern )
Gathers all notes whose StringAttribute contains the data string or matches the pattern regular expression.
For a negative match, where the string is not matched, use an alternate syntax with a preceding exclamation mark (!):
!StringAttribute( data or pattern )
Note how the '!' that triggers the match reversal is placed before the attribute name and not the (data or pattern) part. Thus, opposing examples:
Text(smith)
!Text(smith)
The above two example would have no overlap in their matches. N.B. the $ prefix is not used before the attribute name.
SetAttribute( data or pattern )
Gathers all notes whose SetAttribute values match the data string or matches the pattern regular expression. Unlike a string attribute value where partial matches can be made, the match here must be for a complete individual set value.
Thus for an Set called MySet with three values 'Carpet;Carrot;Car;', a query for $MySet(Ca)
would return no matches. This is because the string 'Ca' is not a complete match for any of the values. MySet(Car)
would get 1 match only - 'Car'. Despite both other values containing the sub-string 'Car', there is no match.
Otherwise the observations above re patterns and negative searches apply.