REGEXP_ILIKE
Returns true if the string contains a match for the regular expression.
Returns true if the string contains a match for the regular expression. REGEXP_ILIKE is similar to the LIKE predicate, except that it uses a case insensitive regular expression, rather than simple wildcard character matching.
This function operates on UTF-8 strings using the default locale, even if the locale is set otherwise.
Important
If you port a regular expression query from an Oracle database, remember that Oracle considers a zero-length string to be equivalent to NULL, while Vertica does not.Syntax
REGEXP_ILIKE ( string-expression, pattern )
Parameters
string-expression
- The
VARCHAR
orLONG VARCHAR
expression to evaluate for matches with the regular expression specified inpattern
. Ifstring-expression
is in the__raw__
column of a flex or columnar table, cast the string to aLONG VARCHAR
before searching forpattern
. pattern
- The regular expression to match against
string-expression
. The regular expression must conform with Perl regular expression syntax.
Examples
This example creates a table containing several strings to demonstrate regular expressions.
-
Create table
longvc
with a single, long varchar columnbody
, and insert data with distinct characters:=> CREATE table longvc(body long varchar (1048576)); CREATE TABLE => insert into longvc values ('На берегу пустынных волн'); => insert into longvc values ('Voin syödä lasia, se ei vahingoita minua'); => insert into longvc values ('私はガラスを食べられます。それは私を傷つけません。'); => insert into longvc values ('Je peux manger du verre, ça ne me fait pas mal.'); => insert into longvc values ('zésbaésbaa'); => insert into longvc values ('Out of the frying pan, he landed immediately in the fire'); => SELECT * FROM longvc; body ------------------------------------------------ На берегу пустынных волн Voin syödä lasia, se ei vahingoita minua 私はガラスを食べられます。それは私を傷つけません。 Je peux manger du verre, ça ne me fait pas mal. zésbaésbaa Out of the frying pan, he landed immediately in the fire (6 rows)
-
Pattern match table rows containing the character
ç
:=> SELECT * FROM longvc where regexp_ilike(body, 'ç'); body ------------------------------------------------- Je peux manger du verre, ça ne me fait pas mal. (1 row)
-
Select all rows that contain the characters
A
/a
:=> SELECT * FROM longvc where regexp_ilike(body, 'A'); body ------------------------------------------------- Je peux manger du verre, ça ne me fait pas mal. Voin syödä lasia, se ei vahingoita minua zésbaésbaa (3 rows)
-
Select all rows that contain the characters
O
/o
:=> SELECT * FROM longvc where regexp_ilike(body, 'O'); body ---------------------------------------------------------- Voin syödä lasia, se ei vahingoita minua Out of the frying pan, he landed immediately in the fire (2 rows)