REGEXP

USAGE

check REGEXP match

Value Name

Description

check

The string to search

match

The regular expression match string

DETAILS

The REGEXP operator matches a regular expression match string against a check string. A 1 (true) is returned if they match, otherwise a 0 (false) is returned.

The match string must be a valid regular expression.

The regular expression is not required to match the full ''check`` value unless you anchor the expression to match at the start and end of the string.

Regular expression matching respects multiple character boundaries, so specifying a . (dot) can match a multi-byte encoded character and will never partially match individual bytes within multi-character encoded strings.

Any non-string arguments are converted to their string representation.

A NULL is returned if either input value is NULL.

The operator x REGEXP y behaves in exactly the same manner as the function call REGEXP(x, y).

SYNONYMS

The following are synonyms for REGEXP:

  • RLIKE

SCHEMA

PARAMETERS

SKYSQL

PRIVILEGES

EXAMPLES

SELECT 'This is a test' REGEXP 't.sts?' AS result1,
       '3' REGEXP 3 AS result2;
+---------+---------+
| result1 | result2 |
+---------+---------+
|       1 |       1 |
+---------+---------+
SELECT 'Hello there' REGEXP '^e';
+---------------------------+
| 'Hello there' REGEXP '^e' |
+---------------------------+
|                         0 |
+---------------------------+
CREATE TABLE regexp_example (
  description VARCHAR(20),
  example INT
);
INSERT INTO regexp_example VALUES
  ('Everything', 42),
  ('Dalmations', 101),
  ('Agent', 99),
  ('B. Doz.', 13),
  ('CPU', 64);
SELECT *
FROM regexp_example
WHERE description REGEXP 'ing$|^....t';
+-------------+---------+
| description | example |
+-------------+---------+
| Everything  |      42 |
| Agent       |      99 |
+-------------+---------+
-- Note that a backslash needs to be doubled due to string escaping
SELECT *
FROM regexp_example
WHERE description REGEXP '\\.';
+-------------+---------+
| description | example |
+-------------+---------+
| B. Doz.     |      13 |
+-------------+---------+

ERROR HANDLING

FEATURE INTERACTION

RESPONSES

DIAGNOSIS

ISO 9075:2016

CHANGE HISTORY

Release Series

History

23.09

  • Present starting in MariaDB Xpand 23.09.1.

6.1

  • Present starting in MariaDB Xpand 6.1.0.

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.1

  • Present starting in MariaDB Xpand 6.1.0.

EXTERNAL REFERENCES