TiddlyWiki5/editions/tw5.com/tiddlers/filters/search.tid

47 lines
3.2 KiB
Plaintext

caption: search
created: 20140410103123179
modified: 20230711084359603
op-input: a [[selection of titles|Title Selection]]
op-neg-output: those input tiddlers in which <<.em not>> all of the search terms can be found
op-output: those input tiddlers in which <<.em all>> of the search terms can be found in the value of field <<.place F>>
op-parameter: one or more search terms, separated by spaces, or a literal search string
op-purpose: filter the input by searching tiddler content
op-suffix: the <<.op search>> operator uses a rich suffix, see below for details
tags: [[Filter Operators]] [[Common Operators]] [[Field Operators]] [[Negatable Operators]]
title: search Operator
type: text/vnd.tiddlywiki
<<.from-version "5.1.18">> The search filter operator was significantly enhanced in 5.1.18. Earlier versions do not support the extended syntax and therefore do not permit searching multiple fields, or the ''literal'' or ''casesensitive'' options.
The <<.op search>> operator uses an extended syntax that permits multiple fields and flags to be passed:
```
[search:<field list>:<flag list>[<parameter>]]
```
* ''field list'': a comma delimited list of field names to restrict the search
** defaults to <<.field tags>>, <<.field text>> and <<.field title>> if blank
** an asterisk `*` instead of the field list causes the search to be performed across all fields available on each tiddler
** preceding the list with a minus sign `-` reverses the order so that the search is performed on all fields except the listed fields
* ''flag list'': a comma delimited list of flags (defaults to `words` if blank)
* ''parameter'': filter parameter
This example searches the fields <<.field title>> and <<.field caption>> for a case-sensitive match for the literal string <<.op-word "The first">>:
```
[search:title,caption:literal,casesensitive[The first]]
```
The available flags are:
* Search mode - the first to be set of the following flags determines the type of search that is performed:
** ''literal'': considers the search string to be a literal string, and requires an exact match
** ''whitespace'': considers the search string to be a literal string, but will consider all runs of whitespace to be equivalent to a single space. Thus `A B` matches `A B`
** ''regexp'': treats the search string as a regular expression. Note that the ''regexp'' option obviates the need for the older <<.olink regexp>> operator.
** ''words'': (the default) treats the search string as a list of tokens separated by whitespace, and matches if ''all of the tokens'' appear in the string (regardless of ordering and whether there is other text in between)
** ''some'': <<.from-version "5.2.2">> treats the search string as a list of tokens separated by whitespace, and matches if ''at least one'' of the tokens appear in the string
* ''casesensitive'': if present, this flag forces a case-sensitive match, where upper and lower case letters are considered different. By default, upper and lower case letters are considered identical for matching purposes.
* ''anchored'': <<.from-version "5.1.20">> anchors the search to the start of the string (applies to ''whitespace'', ''literal'' and ''words'' modes)
<<.operator-examples "search">>