Not regexp Operator in MySQL

The Not Regexp expression returns all the records that do not match a pattern. The basic syntax is

Select <column_names> from <table-names> where <column-name> NOT REGEXP <pattern>

Not Regexp with ^ in MySQL

To filter our records that start with the pattern.

select * from film where title not regexp '^A';

Not Regexp with $ in MySQL

To filter out records that end with the letter k, we do -

select * from film where title not regexp 'k$';

Not Regexp with {} in MySQL

To filter out records with a particular length, we do-

select * from film where title not regexp '^.{10}$';

Not Regexp with the | operator in MySQL

To filter out records with an either-or i.e. | operator, we do-

select * from film where description not regexp 'Awe-inspiring | Touching';

Get all the records that do not have the characters in MySQL

To get all such records that do not contain the characters between the square brackets, we do- 

select * from customer where first_name not regexp '[A,D,B]'
order by first_name;