[[Filters]] follow a formal grammar that is presented here for users who are familiar with the notation. It isn't necessary to understand this grammar in order to write your own filter expressions.
At the end of parsing you end up with some or all of:
* ''<opt-operation-prefix>''
* ''<opt-operator-prefix>''
* ''<operator-name>''
* ''<opt-operator-suffix>'', and
* ''<operand>''
These are used differently by the different operators. For example, the field filter operator supports:
* ''<opt-operator-prefix>'' to negate the result
* ''<regex>'' or ''<string>'' operand (note that this must be explicitly supported by each filter operator)
* ''<opt-operator-suffix>'' to specify a fieldname against which to filter
NOTES:
* The ''<string>'' is a terminal that generally supports single- or double- quoted strings which match, respectively, strings of non-single and non-double quotes. Unquoted strings include the extra exclusion of whitespace and square bracket characters.
* In the case where the ''<string-or-operator-list>'' is NOT an ''<operation>'' it is treated as the operand passed to the default operator (see next bullet). It is not parsed as a full ''<operation>''.
* If ''<operator-name>'' is the empty string then it will be set to "title" (i.e. the title filter operator is the default operator)
* Results are collected and each operation is applied in turn. The ''<opt-operation-prefix>'' can be used to specify how the corresponding operation is used. Suppose T is the set of all tiddlers, R0 is the current set of results, and Fx is the xth operation. Then:
** No prefix (""): R0 = R0 U Fx(T) (set union)
** "-": R0 = R0 - Fx(T) (set difference)
** "+": R0 = Fx(R0)
Note that ''<filter-operand>''s are not commutative!
* The parser was simplified by treating regex "/" as a "bracket" of sorts, meaning there could only be a start and end bracket. Thus the regex arguments, like i, are included in parenthesis immediately following the trailing "/".