Performs a Regex match and returns 1 if the given pattern matches and 0 if not. This filter can typically be used to test a value in an if conditional.
@{ variable | match (regex) }
Parameters
- regex
- A valid regex pattern, wrapped in delimiters like
"/pattern/". Note that you will have to use double backslashes\\to escape reserved characters in regex patterns.
Example
The following example checks whether a template name contains the word post and therefore uses a different date format:
<@ if @{ :template | match ('/post/') } @>
@{ date | dateFormat (@{ formatPost }) }
<@ else @>
@{ date | dateFormat (@{ formatProject }) }
<@ end @>