regexp_like()

A function determining whether a regular expression occurs in a string
This entry relates to a PostgreSQL feature which is part of PostgreSQL 15, due to be released in late 2022.

regexp_like() is a system function determining whether a match for a POSIX regular expression occurs in the provided string.

regexp_like() was added in PostgreSQL 15.

Usage

regexp_like ( string text, pattern text [, flags text ] ) → boolean

A list of flags which can be used with regexp_like() is available in the PostgreSQL documentation: ARE Embedded-Option Letters.

Note that regexp_like() provides equivalent functionality to the ~ operator, or if used with the "i" flag, the ~* operator.

Change history

Examples

Basic usage example for regexp_like():

postgres=# SELECT regexp_like('foobarboo flooobilooo', 'fo{1,}');
 regexp_like
-------------
 t
(1 row)

This is equivalent to:

postgres=# SELECT 'foobarboo flooobilooo' ~ 'fo{1,}';
 ?column?
----------
 t
(1 row)

Matching is case-sensitive by default:

postgres=# SELECT regexp_like('foobarboo flooobilooo', 'Fo{1,}');
 regexp_like
-------------
 f
(1 row)

The "i" flag can override this:

postgres=# SELECT regexp_like('foobarboo flooobilooo', 'Fo{1,}', 'i');
 regexp_like
-------------
 t
(1 row)

This is equivalent to:

postgres=# SELECT 'foobarboo flooobilooo' ~* 'Fo{1,}';
 ?column?
----------
 t
(1 row)

Categories

String manipulation, System function

See also

regexp_count(), regexp_instr(), regexp_substr(), regexp_match(), regexp_matches(), regexp_replace()