Home > Database > Mysql Tutorial > Why Does MySQL\'s Regular Expression Throw \'Repetition-Operator Operand Invalid\' and How Can I Fix It?

Why Does MySQL\'s Regular Expression Throw \'Repetition-Operator Operand Invalid\' and How Can I Fix It?

DDD
Release: 2024-11-25 03:58:14
Original
809 people have browsed it

Why Does MySQL's Regular Expression Throw

#1139 - Error 'Repetition-Operator Operand Invalid' in MySQL Regular Expression

Attempts to utilize a regular expression to retrieve data from a MySQL table often encounter the error "repetition-operator operand invalid." This article delves into the cause of this error and provides a solution.

Cause of the Error

Unlike Perl Compatible Regular Expressions (PCRE), MySQL uses Henry Spencer's POSIX 1003.2-compliant implementation. Therefore, it does not support the question mark (?) modifier, which denotes non-greedy (lazy) quantifiers like *? and ?.

Solution

To resolve this issue, replace the non-greedy quantifier with its greedy counterpart. Additionally, consider using a negated character class to prevent matches on elements like some style/" src="a.png"> and

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template