Skip to content
Legacy docs for Tenzir v5.x. For the latest Tenzir v6 series, visit docs.tenzir.com. Migrating from v5? Read the Tenzir v6 migration guide.

Checks if a string partially matches a regular expression.

match_regex(input:string, regex:string) -> bool

The match_regex function returns true if regex matches a substring of input.

To check whether the full string matches, you can use ^ and $ to signify start and end of the string.

The string to partially match.

The regular expression try and match.

The supported regular expression syntax is RE2. In particular, this means that lookahead (?=...) and lookbehind (?<=...) are not supported by match_regex at the moment.

from {input: "Hello There World"},
{input: "hi there!"},
{input: "Good Morning" }
output = input.match_regex("[T|t]here")
{input: "Hello There World", output: true}
{input: "hi there!", output: true}
{input: "Good Morning", output: false}
from {input: "example"},
{input: "Example!"},
{input: "example?" }
output = input.match_regex("^[E|e]xample[!]?$")
{input: "example", output: true}
{input: "example!", output: true}
{input: "example?", output: false}

Last updated: