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