NOT REGEXP
This page is part of MariaDB's Documentation.
The parent of this page is: SQL Operators for MariaDB Xpand
Topics on this page:
Overview
Negated Regular Expression matching.
USAGE
check NOT REGEXP match
Value Name | Description |
---|---|
| A string expression to check. |
| A regular expression match string. |
DETAILS
The NOT REGEXP
operator works in a similar manner to the REGEXP operator but with the opposite return value. See that operator's description for how the regular expression matching works.
EXAMPLES
SELECT 'Hello there' NOT REGEXP 'the';
+--------------------------------+
| 'Hello there' NOT REGEXP 'the' |
+--------------------------------+
| 0 |
+--------------------------------+
SELECT 'Hello there' NOT REGEXP '^e';
+-------------------------------+
| 'Hello there' NOT REGEXP '^e' |
+-------------------------------+
| 1 |
+-------------------------------+
CREATE TABLE not_regexp_example (
description VARCHAR(20),
example INT
);
INSERT INTO not_regexp_example VALUES
('Everything', 42),
('Dalmations', 101),
('Agent', 99),
('B. Doz.', 13),
('CPU', 64);
SELECT *
FROM not_regexp_example
WHERE description NOT REGEXP 'ing$|^....t';
+-------------+---------+
| description | example |
+-------------+---------+
| Dalmations | 101 |
| B. Doz. | 13 |
| CPU | 64 |
+-------------+---------+
-- Note that a backslash needs to be doubled due to string escaping
SELECT *
FROM not_regexp_example
WHERE description NOT REGEXP '\\.';
+-------------+---------+
| description | example |
+-------------+---------+
| Everything | 42 |
| Dalmations | 101 |
| Agent | 99 |
| CPU | 64 |
+-------------+---------+