Home >Database >Mysql Tutorial >Why Does MySQL\'s Regular Expression Throw \'Repetition-Operator Operand Invalid\' and How Can I Fix It?
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.
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 ?.
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/"> 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!