1

I'm trying to update a field which contains HTML and I want to find all the rows that have forms in them and remove the form tags and anything in between them, however I'm running into problems with my select and the regex.

SELECT * FROM db.table WHERE body REGEXP "<form[^>].+?>.+?</form>";

and the error I get says: 'repetition-operator operand invalid' from regexp.

I was hoping to make that SELECT into a subselect for an update query but I'm stuck at this point.

1 Answer 1

1

I think your problem is in your form expression. Try the following:

"<form[^>]*>.+?</form>"

Remember that MySQL supports a limited set of regular expression matching and testing.

See this document.

Sign up to request clarification or add additional context in comments.

1 Comment

Ahh, I wasn't aware MySQL had limitations for regex. It seems that using .+? doesn't work but changing it to be greedy using * works. Thanks for the insight.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.