This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

filter Operator

22nd May 2021 at 4:25pm
purposeapply a subfilter to each input title and return the titles that return a non-empty result from the subfilter
inputa selection of titles passed as input to the filter
! inputa selection of titles passed as input to the filter
parameterS=a filter expression
outputthe selection of titles that pass the filter S
! outputthose input titles that do not pass the filter S

Learn more about how to use Filters

Introduced in v5.1.23 The filter operator runs a subfilter for each input title, and returns those input titles for which the subfilter returns a non-empty result (in other words the result is not an empty list). The results of the subfilter are thrown away.

Simple filter operations can be concatenated together directly (eg [tag[HelloThere]search[po]]) but this doesn't work when the filtering operations require intermediate results to be computed. The filter operator can be used to filter on an intermediate result which is discarded. To take the same example but to also filter by those tiddlers whose text field is longer than 1000 characters:

<$vars myfilter="[get[text]length[]compare:integer:gteq[1000]]">
<$list filter="[tag[HelloThere]search[po]filter<myfilter>]">
<div>
<$link>
<$text text=<<currentTiddler>>/>
</$link>
</div>
</$list>
</$vars>

Note that within the subfilter, the "currentTiddler" variable is set to the title of the tiddler being processed. The value of currentTiddler outside the subfilter is available in the variable "..currentTiddler". Introduced in v5.2.0

Tip
Compare with the similar subfilter operator which runs a subfilter and directly returns the results

Tip
Compare with the analogous named filter run prefix :filter

\define larger-than-1k() [get[text]length[]compare:integer:gteq[1000]]

{{{ [tag[HelloThere]filter<larger-than-1k>] }}}

is equivalent to:

{{{ [tag[HelloThere]] :filter[get[text]length[]compare:integer:gteq[1000]] }}}

Examples