![]() |
Need help with regexp (or strip_tags maybe?) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Need help with regexp (or strip_tags maybe?) (/showthread.php?tid=13454) |
Need help with regexp (or strip_tags maybe?) - El Forum - 11-23-2008 [eluser]hugle[/eluser] Hello everyone. I'm playing with regexp with no luck. Currently I have this string: Code: <td style=\"padding: 0in 5.4pt; width: 0.5in; border: medium 1.5pt 1.5pt medium none solid solid none -moz-use-text-color windowtext windowtext -moz-use-text-color;\" width=\"48\"> Code: <td><strong>7n./6d.</strong></td> I'm sure some of you are smarter on this than me. Thank you in advance! Need help with regexp (or strip_tags maybe?) - El Forum - 11-23-2008 [eluser]mihailt[/eluser] why don't you use php support for work with DOM? http://www.php.net/manual/en/book.dom.php Need help with regexp (or strip_tags maybe?) - El Forum - 11-23-2008 [eluser]NogDog[/eluser] If the goal is remove any style attribute from any TD tag: Code: $text = preg_replace('#(<td\s[^>]*)style=([\'"]).*\2([^>]*>)#isU', "$1$3", $text); Need help with regexp (or strip_tags maybe?) - El Forum - 11-25-2008 [eluser]hugle[/eluser] mihailt, I will look into it. didn't ever hear about it. NogDog: thanks, but your example didn't work.. I found different sollution: Code: $text = '<a href="" style="font-size: 25px;">test</a>'; so here in $aAllowedTags = array('<a>') you put tags, you want to keep. and in: $aDisabledAttributes = array('style') you put attributes you want to cut. for example: $aDisabledAttributes = array('onabort', 'onblue', 'onchange', 'onclick', 'ondblclick', 'onerror', 'onfocus', 'onkeydown', 'onkeyup', 'onload', 'onmousedown', 'onmousemove', 'onmouseover', 'onmouseup', 'onreset', 'onresize', 'onselect', 'onsubmit', 'onunload') etc... Hope it helps someone who hits this post ![]() |