replace
Performs a regular expression search and replace.
@{ text | replace (regex, replace) }
Parameters
- regex
- A valid regular expression, wrapped in delimiters like
"/pattern/". - replace
- The replacement string. Note that you can make use of backreferences like
$1to$nas described here.
Note that you will have to use double backslashes
\\to escape reserved characters in regex patterns.
Example
The following example will first parse all Markdown in a variable called text and then wrap everything enclosed with double curly brackets in a <div>:
@{ text |
markdown |
replace (
'/\\{\\{(.*?)\\}\\}/is',
'<div class="wrapper">$1</div>'
)
}