[Solved] Regex to remove white spaces [closed]


I assume that you’re using php, based on that, try this:

<?
$text = "#id .class .anotherclass { color: #555 } #anotherid .class { color : #fff; }";
function removespaces($matches)
{
return $matches[1].str_replace(" ", "", $matches[2]);
}
echo preg_replace_callback( "/(#.*?)(\{.*?\})/i", "removespaces", $text);
?>

DEMO:

http://ideone.com/T5Qzc6

solved Regex to remove white spaces [closed]