Search and replace filters

There are some filters that allow you to perform comparisons or searches for components. This is the case for the "|match" and "|replace" filters.

  • match is used to test if the argument passed verifies a regular expression passed as the filter’s second argument.
  • replace is used to replace text, and is also followed by a regular expression.
[(#TAG|match{text})]
[(#TAG|replace{text,other text})]

These filters also accept two further parameters, which are the possible modifier argument to the regular expression ("UimsS" by default), and the number the of surrounding parentheses which is "0" (zero) by default:

[(#BALISE|match{text, modifier, capture})]
[(#BALISE|replace{text,other text, modifier, capture})]

Example

// displays "text yes"
[(#VAL{Some good text}|match{text}) yes ]
// displays "yes"
[(#VAL{Some good text}|match{text}|oui) yes ]
// doesn't display anything
[(#VAL{A good house}|match{text}) non ]
// displays "yes"
[(#VAL{A good house}|match{text}|non) yes ]
 
// displays "A fine cat"
[(#VAL{A fine house}|replace{house,cat})]

Author Mark Baber Published : Updated : 13/10/10

Translations : English, français