SQLite glob() Function

The SQLite glob() function checks if a given string matches a given pattern.

Syntax

Here is the syntax of the SQLite glob() function:

glob(pattern, str)

Parameters

pattern

Required. The pattern that uses the Unix file wildcard syntax.

str

Required. String to check.

Return value

The SQLite glob() function returns 1 or 0. If glob() returned 1, indicates whether a given string matches the given pattern; if glob() returned 0, indicates whether a given string does not match the given pattern.

Examples

To check if hello matches the pattern *ell*, use a statement:

SELECT glob('*ell*', 'hello');
glob('*ell*', 'hello')
----------------------
1

Here, hello matches the pattern *ell*.

To check if hello matches the pattern *ee*, use the following statement:

SELECT glob('*ee*', 'hello');
glob('*ee*', 'hello')
---------------------
0

Here, hello does not match the pattern *ee*.