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
Release: 2024-12-03 02:58:09
Original
509 people have browsed it

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template