This is the ThingsDB documentation for version v0, click here for the latest version!

regex

Create a new regular expression.

This function can be used to create a regular expression from a given pattern with optional flags.

This function does not generate an event.

Function

regex(pattern, [flags])

Arguments

Argument Type Description
pattern str (required) The pattern to use as a regular expression.
flags str (optional) Optional flags, see the regex for more information.

Return value

A new regular expression.

Example

Returns a new regular expression from a pattern.

// match strings which start with "the ", case in-sensitive (`i` flag)
re = regex("^the\s", "i");

"The Pretenders".test(re);

Example return value in JSON format

true