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? Link to comment https://forums.phpfreaks.com/topic/80141-howto-strip-more-then-1-string-in-1-statement/ 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' ) Link to comment https://forums.phpfreaks.com/topic/80141-howto-strip-more-then-1-string-in-1-statement/#findComment-406177 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? Link to comment https://forums.phpfreaks.com/topic/80141-howto-strip-more-then-1-string-in-1-statement/#findComment-406216 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. Link to comment https://forums.phpfreaks.com/topic/80141-howto-strip-more-then-1-string-in-1-statement/#findComment-406225 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. Link to comment https://forums.phpfreaks.com/topic/80141-howto-strip-more-then-1-string-in-1-statement/#findComment-406257 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. Link to comment https://forums.phpfreaks.com/topic/80141-howto-strip-more-then-1-string-in-1-statement/#findComment-406260 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.