2014-09-09 14:57:41 +00:00
created: 20140909134102102
2015-02-03 19:29:25 +00:00
modified: 20150203190626000
2015-01-24 21:18:44 +00:00
tags: [[Filter Operators]] [[Field Operators]] [[Negatable Operators]]
title: regexp Operator
2014-09-09 14:57:41 +00:00
type: text/vnd.tiddlywiki
2015-01-24 21:18:44 +00:00
caption: regexp
2015-02-03 19:29:25 +00:00
op-purpose: filter the input by pattern-matched field
op-input: a [[selection of titles|Title Selection]]
2018-08-19 17:37:14 +00:00
op-suffix: the name of a [[field|TiddlerFields]], defaulting to <<.field title>>
2015-02-03 19:29:25 +00:00
op-suffix-name: F
op-parameter: a regular expression
op-parameter-name: X
op-output: those input tiddlers in which field <<.place F>> matches <<.place X>>
op-neg-output: those input tiddlers in which field <<.place F>> does <<.em not>> match <<.place X>>
2014-09-09 14:57:41 +00:00
2015-01-24 21:18:44 +00:00
<<.def "Regular expressions">> are concise strings of characters that denote patterns of text to search for. The format used in ~TiddlyWiki is fully defined in [[this Mozilla reference|https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions]].
2014-09-09 14:57:41 +00:00
2015-01-24 21:18:44 +00:00
The [[filter syntax|Filter Run]] makes it impossible to directly specify a regular expression that contains square brackets. The solution is to store the expression in a [[variable|Variables]]. See the <<.operator-examples "regexp" "examples">>.
2014-09-09 14:57:41 +00:00
2015-02-03 19:29:25 +00:00
The parameter <<.place X>> can optionally start or end with a string of flags:
2014-09-10 17:25:38 +00:00
2015-01-24 21:18:44 +00:00
<$railroad text=""" "(?" { ("i"|"m"|:"g") } ")" """/>
2014-09-10 17:25:38 +00:00
2015-01-24 21:18:44 +00:00
Only the `i` flag is generally useful: it forces the different between capital and lowercase letters to be ignored.
2014-09-10 17:25:38 +00:00
2015-02-03 19:29:25 +00:00
If <<.place X>> is empty, <<.op regexp>> will match all of the input tiddlers.
2014-09-10 17:25:38 +00:00
2015-01-24 21:18:44 +00:00
<<.operator-examples "regexp">>