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.
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!