REGEX_MATCH()

All functions > STRING > REGEX_MATCH()

Returns TRUE if the entire string matches the regular expression pattern. Unlike REGEX_CONTAINS, this requires the pattern to match the full string, not just a substring.

Signatures

Returns: TRUE if the entire string matches the pattern, FALSE if it does not; NULL if either argument is NULL

REGEX_MATCH(string: VARCHAR, pattern: VARCHAR) → BOOLEAN
sql
ParameterTypeRequiredDescription
stringVARCHARYesString to test
patternVARCHARYesRegular expression pattern that must match the entire string

Notes

  • The pattern is implicitly anchored to match the full string; you do not need to add ^ and $
  • If you only need a substring match, use REGEX_CONTAINS instead
  • Matching is case-sensitive unless the pattern uses an inline case-insensitivity flag (e.g. (?i) where supported)
  • Returns FALSE when there is no match (not NULL)
  • Invalid patterns typically fail the query with an error rather than returning FALSE

See also

Examples

FeatureQL
SELECT
    f1 := REGEX_MATCH('hello', 'hello'), -- Exact literal match
    f2 := REGEX_MATCH('hello world', 'hello'), -- Substring does not count
    f3 := REGEX_MATCH('hello world', 'hello.*'), -- Wildcard matches rest
    f4 := REGEX_MATCH('abc123', '[a-z]+[0-9]+'), -- Full pattern match
    f5 := REGEX_MATCH('abc123def', '[a-z]+[0-9]+'), -- Trailing chars cause failure
    f6 := REGEX_MATCH('2024-01-15', '\d{4}-\d{2}-\d{2}'), -- Date format validation
    f7 := REGEX_MATCH('user@example.com', '.+@.+\..+'), -- Email format validation
    f8 := REGEX_MATCH(NULL(VARCHAR), 'x'), -- NULL haystack
    f9 := REGEX_MATCH('hello', NULL(VARCHAR)) -- NULL pattern
;
Result
f1 BOOLEANf2 BOOLEANf3 BOOLEANf4 BOOLEANf5 BOOLEANf6 BOOLEANf7 BOOLEANf8 BOOLEANf9 BOOLEAN
truefalsetruetruefalsetruetrueNULLNULL

Last update at: 2026/05/26 17:22:09