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
DDDOriginal
2024-11-25 03:58:14895browse

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 Why Does MySQL\'s Regular Expression Throw \'Repetition-Operator Operand Invalid\' and How Can I Fix It?some style/"> and

%<img  alt="Why Does MySQL\'s Regular Expression Throw \'Repetition-Operator Operand Invalid\' and How Can I Fix It?" >]*src="http://www'

Note that the " character is not escaped, and the .* at the start is implied.

The above is the detailed content of Why Does MySQL\'s Regular Expression Throw \'Repetition-Operator Operand Invalid\' and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn