NOT REGEXP
Description
NOT REGEXP is used to test whether a string does not match a specified regular expression.
If column_name does not match pattern, it returns TRUE. If it matches, it returns FALSE.
Syntax
1. > column_name NOT REGEXP pattern
Explanations
column_nameis the column to match.patternis the regular expression to apply.
Examples
1. CREATE TABLE example (
2. id INT AUTO_INCREMENT,
3. text VARCHAR(255),
4. PRIMARY KEY(id)
5. );
8. INSERT INTO example (text)
9. VALUES ('Hello1'),
10. ('Hello2'),
11. ('World'),
12. ('HelloWorld'),
13. ('Hello_World'),
14. ('example'),
15. ('example1'),
16. ('example2');
18. mysql> SELECT * FROM example WHERE text NOT REGEXP '[0-9]';
19. +------+-------------+
20. | id | text |
21. +------+-------------+
22. | 3 | World |
23. | 4 | HelloWorld |
24. | 5 | Hello_World |
25. | 6 | example |
26. +------+-------------+
27. 4 rows in set (0.00 sec)
