Home >Database >Mysql Tutorial >MySQL REGEXP Error \'#1139 - Got error \'repetition-operator operand invalid\': How to Fix Non-Greedy Quantifier Issues?

MySQL REGEXP Error \'#1139 - Got error \'repetition-operator operand invalid\': How to Fix Non-Greedy Quantifier Issues?

Susan Sarandon
Susan SarandonOriginal
2024-12-03 02:58:09462browse

MySQL REGEXP Error

1139 - Got error 'repetition-operator operand invalid' from regexp

When attempting to utilize a regular expression to retrieve specific results from a MySQL table, you may encounter the error message:

"#1139 - Got error 'repetition-operator operand invalid' from regexp"

To resolve this issue, understand that MySQL employs Henry Spencer's implementation of regular expressions, which adheres to POSIX 1003.2. This implementation lacks support for using the question mark (?) as a non-greedy (lazy) modifier to the star (*) and plus ( ) quantifiers, as is possible in PCRE (Perl Compatible Regular Expressions).

To rectify the error, opt for the greedy version of the quantifier instead, which should yield the desired results. However, to prevent matching undesired patterns (e.g., some style/" src="a.png">), consider using a negated character class:

"1*src="http://www""

Note that the " character does not require escaping, and the .* at the start of the expression is implied.


  1. >

    The above is the detailed content of MySQL REGEXP Error \'#1139 - Got error \'repetition-operator operand invalid\': How to Fix Non-Greedy Quantifier Issues?. 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