ts24 Posted December 4, 2007 Share Posted December 4, 2007 I have to strip several strings like <br />, <strong>, <b> etc. in a field Now I use: replace(SUBSTRING(products_description.products_description,1, 400), '<br />', ' ') AS description, But how can I strip more then 1 string in 1 statement? Quote Link to comment Share on other sites More sharing options...
fenway Posted December 4, 2007 Share Posted December 4, 2007 If only mysql supported proper regex capturing parentheses... in the meanwhile, you'll have to nest your replaces: replace( replace( col1, 'old', 'new' ), 'old2', 'new2' ) Quote Link to comment Share on other sites More sharing options...
ts24 Posted December 4, 2007 Author Share Posted December 4, 2007 With more then 15 strings it is not the real solution. Can I do it within a case statement? Quote Link to comment Share on other sites More sharing options...
fenway Posted December 4, 2007 Share Posted December 4, 2007 You'd still have to list all 15 old/new values... there is no "real" solution, mysql wasn't meant to do string manipulation. Why do it in mysql anyway? HTML Tidy can handle this for you. Quote Link to comment Share on other sites More sharing options...
ts24 Posted December 4, 2007 Author Share Posted December 4, 2007 I have to do this because it is a direct manual query to the table for export data into a feed file for external usage. Not within our shop, but a direct MYSQL interface to export the data. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 4, 2007 Share Posted December 4, 2007 If that's the case, then just run the nested replace()... that's the best you can do... unless you write a UDF and run it on insert/update and store the cleaned value in another field. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.