SQLite Forum

REGEXP (X) bug
Login

REGEXP (X) bug

(1.1) By Mark Scandariato (scandariato) on 2022-07-15 19:42:51 edited from 1.0 [source]

Here's a separate oddity - the first three are correct.

SQLite version 3.39.1 2022-07-13 19:41:41
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> select 1 WHERE 'foo' REGEXP '[a-z]';
1
sqlite> select 1 WHERE 'foo' REGEXP '^[a-z]+$';
1
sqlite> select 1 WHERE 'foo' REGEXP '^([a-z]+)$';
1
sqlite> select 1 WHERE 'foo' REGEXP '(^[a-z]+)$';
sqlite> select 1 WHERE 'foo' REGEXP '(^[a-z]+$)';
Runtime error: unmatched '('
sqlite> 

(2) By Mark Scandariato (scandariato) on 2022-07-15 21:29:43 in reply to 1.1 [link] [source]

The latest version of ext/misc/regexp.c on the trunk fixes the $ problem but not the ^ problem:

SQLite version 3.39.1 2022-07-13 19:41:41
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .load regexp.so
sqlite> select 1 WHERE 'foo' REGEXP '([a-z]+$)';
1
sqlite> select 1 WHERE 'foo' REGEXP '(^[a-z]+$)';
sqlite> 

This looks like the same problem as issue #2 from https://sqlite.org/forum/forumpost/96692f8ba5.