2023
MariaDBERRORNotableQueryHIGH confidence

Error in regular expression

Production Risk

Low — query is rejected.

What this means

A regular expression used in a REGEXP, RLIKE, or REGEXP_LIKE() clause contains a syntax error. MySQL uses the ICU regex library in MySQL 8.0 and POSIX regex in 5.x.

Why it happens
  1. 1Malformed regex pattern (unbalanced brackets, invalid quantifiers, etc.).
  2. 2Using PCRE-specific syntax not supported by the MySQL regex engine.
  3. 3Invalid character class or backreference in the pattern.
How to reproduce
trigger — this will error
trigger — this will error
SELECT * FROM t WHERE col REGEXP '[invalid';

expected output

ERROR 2023 (HY000): Got error 'missing terminating ] for character class' from regexp.

Fix 1

Correct the regular expression syntax

Correct the regular expression syntax
SELECT * FROM t WHERE col REGEXP '[a-z]+';

Why this works

A valid regex pattern resolves the parsing error.

Fix 2

Test the regex pattern independently before using in SQL

Test the regex pattern independently before using in SQL
SELECT REGEXP_LIKE('test_value', '[a-z]+');

Why this works

Isolating the regex test helps identify syntax issues quickly.

What not to do

Version notes

Sources
Official documentation ↗

MySQL 8.0 — 2023 ER_REGEXP_ERROR

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors