JohnK
JohnK

Reputation: 21

MySQL search for text in html text field?

There is a CKEditor field on our website which saves it's HTML to a text field in a MySQL database.

What I'm wondering is, if there is a function (regex for example?) that could strip out HTML tags when doing a LIKE match,

e.g. so that searching for:

like '%this is a test%'

would find

'this<strong>is</strong>a test

I get the feeling that it won't be practical/possible, but worth an ask!

Upvotes: 0

Views: 1172

Answers (1)

BBonifield
BBonifield

Reputation: 5003

I think your better bet would be to strip all of the HTML and store a plain-text version of that in your database table. As Ether noted though, don't use REGEX to remove the HTML when you do it.

Upvotes: 1

Related Questions