tags:

views:

25

answers:

1

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!

+1  A: 

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.

BBonifield
Agreed. If you're going to be doing a lot of those kinds of searches, it's worth the extra space in your DB.
Michael Mior
Thanks for the comments, unfortunately I can't add a field to the database, however I got around the problem by spliting each word of the search phrase and doing like '%firstword%' and like '%secondword%' etc etc. Not ideal in every scenario granted, but the client is happy with this solution, for now at least!
JohnK