Regexp to filter style from HTML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kidko
    New Member
    • Apr 2007
    • 17

    Regexp to filter style from HTML

    I'm trying to strip out the "style" attribute from a bit of user input. If the user input is $input, why wouldn't the following, given
    Code:
    <tag style="blah" href="site">Content</tag>
    leave me with
    Code:
    <tag href="site">Content</tag>
    It doesn't take out anything at all!

    Code:
    $strip_regexp = array('/(.*)style=\".*\"(.*)/', '/(.*)style=\'.*\'(.*)/');
    $input = preg_replace($strip_regexp, "$1$2", $input); // apply strip_regexp
Working...