regexp
Package regexp provides Go-regexp-syntax SQL functions plus the binary REGEXP operator SQLite leaves unimplemented by default.
Functions
Section titled “Functions”- regexp(pattern, text) → BOOL: REGEXP operator backing.
- regexp_like(text, pattern) → BOOL.
- regexp_count(text, pattern [, start]) → INTEGER.
- regexp_instr(text, pattern [, start [, N [, endoption [, subexpr]]]]) → INTEGER.
- regexp_substr(text, pattern [, start [, N [, subexpr]]]) → TEXT.
- regexp_replace(text, pattern, replacement [, start [, N]]) → TEXT.
Implementation uses the standard regexp package. Patterns follow RE2 syntax; PCRE-only features (backreferences, lookahead, etc.) are not supported and surface as a “regexp: parse pattern: …” error.
Position arguments (start, N, subexpr) are 1-based to match the nalgeon/sqlean convention. start defaults to 1, N defaults to 1 (first match), subexpr defaults to 0 (whole match).
Ported from ncruces/ext/regexp with the same function lineup and semantics.
import ( sqlite "gosqlite.org" "gosqlite.org/ext/regexp")
if err := regexp.Register(conn); err != nil { ... }
rows, _ := db.Query(`SELECT name FROM users WHERE name REGEXP ?`, `^[A-Z]`)For pool-wide install via gosqlite.org.Driver.ConnectHook, blank-import the auto sub-package:
import _ "gosqlite.org/ext/regexp/auto"Full API: pkg.go.dev/gosqlite.org/ext/regexp