removing html attributes by preg_replace
[email protected] ("Tomas Lehuta") Mon, 17 Feb 2003 14:44:52 +0100
| Newsgroups | php.general,php.lang |
|---|---|
| Message-ID | <[email protected]> |
hello!
could somebody please help me to build a regexp to strip some attributes
from html code?
i'd like to remove all class="" attributes from html, but the example below
seems not match
i don't know what i'm doing wrong, this simply doesn't work!
<?php
$html = '<A href="http://www.anywhere.com" class="link"></A>';
echo "input:<br>".htmlspecialchars($html)."<hr>";
$html = preg_replace("|(<\w+[^>]*) +class=\"?.*\"?([^>]*)|iU", \\1\\2,
$html);
echo "output:<br>".htmlspecialchars($html)."<hr>";
?>
input:
<A href="http://www.anywhere.com" class="link"></A>
output:
<A href="http://www.anywhere.com""link"></A>
why this always removes 'class=' only???
thanx for any help
-lharp-
_________________
aurius media studio
http://www.aurius.sk