Possible Duplicate:
Allow user submitted HTML in PHP
I’m building a small tool that publishes web articles to our website. A lot of the times our users are copying and pasting directly from Microsoft Word into my wysiwyg editor. The editor copies all of the Word hidden tags.
My main issue I am trying to address is removing <span>. Word often throws in a lot of style attributes after the <span> tag. For example: <span style=" Arial, sans-serif; font-size: 10pt; ">.
Is there a way to remove the entire span tag? Regex?
If you’re set on using a regex for it you could try something like
Where the
(<span)+(>)+catches both opening and closing tags and the middle section should catch any attributes declared inline. Then you could use php preg_replace to replace all occurrences of this pattern with empty quotes or something like that.http://www.php.net/manual/en/function.preg-replace.php