match_regex

Description

Return true if the argument input string or object (converted to a string) matches the argument regular expression.

The last parameter specifies optional regex flags:

  • c - Enables case-sensitive matching (default.)

  • i - Enables case-insensitive matching.

  • m - Enables multi-line mode (i.e. meta-characters ^ and $ match the beginning and end of any line of the input string.) By default, multi-line mode is disabled (i.e. ^ and $ match the beginning and end of the entire input string.)

  • s - Enables the POSIX wildcard character . to match \n (newline.) By default, . does not match \n.

For more about syntax, see POSIX extended regular expressions.

This function returns false for the empty regular expression "" for all inputs. However, it returns true for the empty group "()", for all inputs except null. It returns false in case of invalid arguments or any other error.

Return type

bool

Domain

This is a scalar function (calculates a single output value for a single input row.)

Categories

Usage

match_regex(input, pattern, [ flags ])

Argument

Type

Optional

Repeatable

Restrictions

input

searchable

no

no

none

pattern

regex

no

no

none

flags

string

yes

no

constant

Examples

filter match_regex(log, /^debug/, 'i')

Filter field log for results matching the specified regular expression, using case-insensitive matching.

Aliases

regex_match (deprecated)