MySQL NOT REGEXP Operator

In MySQL, The NOT REGEXP operator returns whether a string mismatches a regular expression.

NOT REGEXP is the negation of REGEXP and it is the same as NOT RLIKE.

NOT REGEXP Syntax

Here is the syntax of the MySQL NOT REGEXP operator:

str NOT REGEXP regexp

It is equivalent to NOT (str REGEXP regexp).

Parameters

str
Required. The string to be tested.
regexp
Required. The regular expression to which the string str is to be matched.

Return value

NOT REGEXP returns 1 if the string str mismatches the gaven regular expression regexp, otherwise it returns 0.

If any parameter is NULL, NOT REGEXP returns NULL.

NOT REGEXP performs a Case-insensitive matching.

NOT REGEXP Examples

Here are some examples of MySQL CHAR() function.

SELECT
    'hello' NOT REGEXP '^[a-z]+$',
    'hello' NOT REGEXP '^[A-Z]+$',
    '12345' NOT REGEXP '[0-9]+$',
    '12345' NOT REGEXP '^\\d+$',
    '123ab' NOT REGEXP '^\\d*$',
    '123ab' NOT REGEXP '^.*$'\G
'hello' NOT REGEXP '^[a-z]+$': 0
'hello' NOT REGEXP '^[A-Z]+$': 0
 '12345' NOT REGEXP '[0-9]+$': 0
  '12345' NOT REGEXP '^\\d+$': 0
  '123ab' NOT REGEXP '^\\d*$': 1
    '123ab' NOT REGEXP '^.*$': 0