Regex: remove whitespaces but not from < > tag

i've been struggling with regexp for ages..what i need is to remove all the whitespaces from a string, but not from < tags > (eg. an a href tag or a img src tag must have whitespaces).I'm doing it in PHP and i'm trying different solutions (i'm a total noob with regexp, and this is so confusing to me).this is the portion of my code so far:\[code\]$text=$_POST["text"];$pattern = '(\<.+?\>)|\s'; $replace = '';echo preg_replace( $pattern, $replace, $text );\[/code\]what's wrong with this? :(
 
Back
Top