string.regex

This function checks whether a regular expression pattern matches a string.

Syntax

string.regex(pattern, str)

Arguments

Argument

Type

Description

pattern

string

Regular expression pattern against which the source string needs to be matched.

str

string

Source string

Returns

Type

Description

boolean

  • True: if the source string matches the regular expression pattern
  • False: if the source string does not match the regular expression pattern

Examples

The function string.regex("foo.*", "seafood") returns true.