At 09:43 PM 3/3/01 , Erick Papadakis wrote:
>Thanks Brian, I have tried the allowable tags, but I need to remove the
>ATTRIBUTES of a tag, not the tag itself. STRIP_TAGS totally removes the tag,
>and ALLOWABLE_TAGS lets the tag be. WHat I wish to do is let the main tag be
>but remove its attributes, as follows:
>
>     Original text:
>         <font class="something" style="....">Hi!</font>
>
>     Parsed text:
>         <font>Hi!</font>
>
>Thanks/erick

Well, in this case, you'd have to use regular expressions. One way to do it 
would be:

         $SanitizedString = 
ereg_replace('<[[:space:]]*([[:alnum:]]+)[^>]*>', "<\\1>", $String);

this _should_  work (haven't tested it). If you wanted to remove some tags 
entirely, and then remove the attributes of the remaining tags, you could 
(1) use strip_tags() with a list of allowable tags, then (2) run the regexp 
above. Incidentally, the above regexp also removes leading spaces from the 
tag. Eg, <   font style="unreadable"> becomes <font>. If you don't want, 
that user the regexp

         '<([[:space:]]*[[:alnum:]]+)[^>]*>'

instead.

         - steve


>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.230 / Virus Database: 111 - Release Date: 25-Jan-01



+------------------------------------------------------------------------+
| Steve Edberg                           University of California, Davis |
| [EMAIL PROTECTED]                                     (530)754-9127 |
| http://aesric.ucdavis.edu/                  http://pgfsun.ucdavis.edu/ |
+---------------------- Gort, Klaatu barada nikto! ----------------------+

Reply via email to