Query Android SQLiteDatabase with Regex

I am trying to get records from SQLiteDatabase in an Android program using the query function using a select parameter. I have had success with simple pattern matching using SQLite LIKE and wildcard%. Now I want to do more complex pattern matching using regular expressions.

According to the SQLite site , for the REGEXP statement to work, it must be user-defined. Has anyone managed to create specific SQLite functions for Android SQLiteDatabase? Or did someone find another way to use regular expressions when searching through strings in a database?

+6
source share
1 answer

As described here

The REGEXP statement is a special syntax for the user-defined regexp () function. The user-defined function regexp () is not defined by default, so using the REGEXP operator usually results in an error message. If an SQL function called "regexp" is added at run time, this function will be called to implement the REGEXP statement.

But there is a GLOB, which is slightly more advanced than LIKE.

+1
source

Source: https://habr.com/ru/post/891824/


All Articles