Repository navigation
Commit 6041922
committed
feat(sqlite): add REGEXP_LIKE, REGEXP_INSTR, REGEXP_SUBSTR and REGEXP_REPLACE
Add the four REGEXP_* functions from the coverage audit (#586), implemented with
PCRE and modelled on the existing regexp operator UDF. Only the REGEXP operator
existed before, so matching inside a WHERE clause worked while the function
forms failed.
The match_type argument maps c, i, m and n onto PCRE flags and defaults to
case-insensitive, matching MySQL's default collations. Positions are 1-based
character indexes, and the replacement expansion handles $1..$99 and $0 itself
rather than delegating to preg_replace(), because MySQL's replacement syntax is
not PCRE's.
Documented divergences: PCRE rather than ICU, so rare dialect differences are
possible; the u flag is accepted and ignored; a lone $ is treated literally to
avoid breaking queries that contain currency amounts; fractional positions are
truncated.
Refs #586, #591.1 parent 70bdaf3 commit 6041922
2 files changed
Lines changed: 740 additions & 0 deletions
File tree
- packages/mysql-on-sqlite
- src/sqlite
- tests
0 commit comments