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
| Parameter | Type | Required | Description |
|---|---|---|---|
string | VARCHAR | Yes | String to search in |
pattern | VARCHAR | Yes | Regular 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_ALLwhen 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 BOOLEAN | f2 BOOLEAN | f3 BOOLEAN | f4 BOOLEAN | f5 BOOLEAN | f6 BOOLEAN | f7 BOOLEAN | f8 BOOLEAN |
|---|---|---|---|---|---|---|---|
| true | true | false | true | false | true | NULL | NULL |
On this page