Return to Snippet

Revision: 10195
at March 13, 2009 05:48 by blubadger


Updated Code
function removeStyle($string) {
	$except = array('font-weight', 'text-decoration', 'color'); // declare your exceptions 
	$allow = implode($except, '|'); 
	$regexp = '@([^;"]+)?(?<!'.$allow.'):(?!\/\/(.+?)\/)((.*?)[^;"]+)(;)?@is'; 
	$out = preg_replace($regexp, '', $string); 
	$out = preg_replace('@[a-z]*=""@is', '', $out); // remove any unwanted style attributes
	return $out;
}

Revision: 10194
at December 12, 2008 04:53 by blubadger


Initial Code
$except = array('font-weight', 'text-decoration', 'color'); // declare your exceptions 
$allow = implode($except, '|'); 
$regexp = '@([^;"]+)?(?<!'.$allow.'):(?!\/\/(.+?)\/)((.*?)[^;"]+)(;)?@is'; 
$out = preg_replace($regexp, '', $content); 
$out = preg_replace('@[a-z]*=""@is', '', $out); // remove any unwanted style attributes

Initial URL


Initial Description


Initial Title
RemoveAttributesStyle

Initial Tags


Initial Language
PHP