Skip to main content

MATCH

Tom Williams avatar
Written by Tom Williams
Updated this week

Type: Function

Function: MATCH

Syntax: MATCH(string, regex) or alternatively, the shorthand version string ~ regex

Description: Returns true if the first argument matches the regular expression provided as the second argument. Also available as ~.

Matching is case-insensitive by default. You can make the regex case sensitive by adding (?c) at the beginning of your regex.

The regex must be a POSIX regular expression. You can use this tool to test regular your expressions

Note that backslashes (\) need to be escaped in strings. So typical regex patterns such as \d will have to be written \\d in regex strings. See the examples below.

Sample usage:

  • MATCH(author_username, "^jo") = author_username ~ "^jo" returns true when the author username starts with "jo".

  • MATCH(url, "github.com") returns true when the URL contains "github.com", otherwise returns false.

  • MATCH("1234", "\\d+") returns true since the string contains numbers.

  • title ~ "(?c)fix" returns true when the title of the item contains "fix" at any place in a case sensitive manner. Otherwise returns false.


​Regular Expression cheat sheet.:

  • "^fix" string starts with "fix"

  • "fix$" string ends with "fix"

  • "(?c)fix" string contains "fix" (case-sensitive)

  • "fix|bug" string contains "fix" or "bug"

  • Test more regular expressions using this tool

Did this answer your question?