Need help with regexp (or strip_tags maybe?) |
[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!
[eluser]mihailt[/eluser]
why don't you use php support for work with DOM? http://www.php.net/manual/en/book.dom.php
[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);
[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 |
Welcome Guest, Not a member yet? Register Sign In |