0

I have a SQLite table called comments with a column called text. I've been trying to make a SQL query that selects all rows where text fulfills the following regular expression: (^|\\W)TEST(\\W|$). Currently, I'm using python to select all rows with TEST, then, running the regex test for each row that is returned. However, speed matters in what I'm doing, and it would be much faster if the SQL query had the regex matching. Here is the current query I have:

SELECT text FROM comments WHERE text LIKE "%TEST%"

How can I use regex in an SQLite query? If not regex, does SQLite have some similarly powerful text-matching syntax?

I'm on Windows 10.

Gbox4
  • 623
  • 2
  • 10
  • SQLite does not have native regex support, but there is a `REGEXP` operator which may be added on via a library. – Tim Biegeleisen Jan 31 '21 at 03:04
  • Someone else solved this problem with python: https://stackoverflow.com/questions/5365451/problem-with-regexp-python-and-sqlite/5365533#5365533 – Gbox4 Jan 31 '21 at 03:56

0 Answers0