I have a snippet of html that needs to be cleaned up. All of the u003d's in html tags need to be converted into =, leaving alone all other u003d's (outside of html tags :p ).
Slurping in the whole html code, and using preg_replace, I have no problem replacing the first occurance of u003d in each tag, but am unable to convert multiple occurances in the same tag.
Example html:
<table widthu003d"600" cellpaddingu003d"0" cellspacingu003d"0" bgcoloru003d"#7b849c" borderu003d"0">
I first used str_replace. Works nicely, except the u003d's outside of tags are also changed. Then I used preg_replace, which only replaces the first occurance. Being creative, I thought I could match the tag and use str_replace. No luck. Suggestions are requested. :o
// only first occurance in each tag, of course
$html = preg_replace(array('/(<[^>]*?)u003d([^>]*?'.'>)/'), array('\\1=\\2'), $html);
// this just does not work, not really surprised
$html = preg_replace(array('/(<[^>]*?u003d[^>]*?'.'>)/e'), array('str_replace("u003d","=",\1)'), $html);
I know the array() is not required as is. It's there so I can expand once this works.