Skip to content

REGEXP

  • expr: This is the string to be processed. REGEXP() function applies the pattern to this string.
  • pat: This denotes the pattern that should be used for matching against the given string. Regular expressions in MySQL are supported through this parameter.
SELECT * FROM employees
WHERE name REGEXP '^[aeiou].*[aeiou]$';
+---------+-------+
| Emp_ID | name |
+---------+-------+
| 1 | Alex |
| 4 | Otto |
+---------+-------+

The REGEXP pattern ’^[aeiou].*[aeiou]$’ matches any name entries in the ‘employees’ table that start and end with a vowel. It returned ‘Alex’ and ‘Otto’ as they meet this criterion.