REGEX_CONTAINS()

All functions > STRING > REGEX_CONTAINS()

Returns TRUE if the haystack string contains a match for the regular expression pattern (substring match; anchors still apply within the search).

Signatures

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

REGEX_CONTAINS(string: VARCHAR, pattern: VARCHAR) → BOOLEAN
sql
ParameterTypeRequiredDescription
stringVARCHARYesString to search in
patternVARCHARYesRegular expression pattern to match

Notes

  • 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
  • Pair with REGEX_EXTRACT_FIRST / REGEX_EXTRACT_ALL when you need the matched text

See also

Examples

FeatureQL
SELECT
    f1 := REGEX_CONTAINS('Hello World', 'World'), -- Literal match
    f2 := REGEX_CONTAINS('Hello World', '^Hello'), -- Anchored at start
    f3 := REGEX_CONTAINS('Hello World', '^World'), -- Anchor fails
    f4 := REGEX_CONTAINS('abc123', '[0-9]+'), -- Digit pattern
    f5 := REGEX_CONTAINS('hello', '[A-Z]'), -- Case-sensitive
    f6 := REGEX_CONTAINS('user@example.com', '.+@.+\..+'), -- Email-like pattern
    f7 := REGEX_CONTAINS(NULL(VARCHAR), 'x'), -- NULL haystack
    f8 := REGEX_CONTAINS('hello', NULL(VARCHAR)) -- NULL pattern
;
Result
f1 BOOLEANf2 BOOLEANf3 BOOLEANf4 BOOLEANf5 BOOLEANf6 BOOLEANf7 BOOLEANf8 BOOLEAN
truetruefalsetruefalsetrueNULLNULL

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