Skip to main content

Regex Operators

When we need to work with regular expressions, these operators will help with your markdown.

List of Operators

{{ toRegex }}

Convert the given string to a regular expression.

Params

  • str
  • returns

Example

{{toRegex "foo"}}
<!-- results in: /foo/ -->

{{ test }}

Returns true if the given str matches the given regex. A regex can be passed on the context, or using the toRegex helper as a subexpression.

Params

  • str
  • returns

Example

{{test "bar" (toRegex "foo")}}
<!-- results in: false -->
{{test "foobar" (toRegex "foo")}}
<!-- results in: true -->
{{test "foobar" (toRegex "^foo$")}}
<!-- results in: false -->