regex crate, which implements a subset of RE2 syntax — the same syntax used by Go and RE2.
The regex engine does not support look-ahead, look-behind, or backreferences. It does support Unicode character classes, anchors, and most common quantifiers.
Functions
| Function | Arguments | Returns | Description |
|---|---|---|---|
regexp(pattern, string) | pattern TEXT, string TEXT | INTEGER (0 or 1) | Returns 1 if string matches pattern, 0 otherwise |
regexp_like(string, pattern) | string TEXT, pattern TEXT | INTEGER (0 or 1) | Same as regexp with arguments reversed |
regexp_substr(string, pattern) | string TEXT, pattern TEXT | TEXT or NULL | Returns the first substring of string matching pattern, or NULL if no match |
regexp_replace(string, pattern, replacement) | string TEXT, pattern TEXT, replacement TEXT | TEXT | Replaces the first match of pattern in string with replacement |
regexp_capture(string, pattern [, group]) | string TEXT, pattern TEXT, group INTEGER | TEXT or NULL | Returns the text of capture group group (default 1) from the first match |
REGEXP operator
Turso supports theREGEXP infix operator in WHERE clauses. It is equivalent to calling regexp(pattern, string):
NOT REGEXP form is also supported:
Examples
Check if a string matches a pattern
Extract the first match
Replace a pattern
Extract a capture group
Filter rows using REGEXP
NULL handling
All functions return NULL when eitherpattern or string is not TEXT (including NULL). An invalid regex pattern also returns NULL.