If you really don't want to use any library and want to stick with regular expressions, this will work for you:
<?php $mycss = "body,div.coul01,.white,.coul01{ color:#000000; } div.coul01,.red,.coul01{ color:#663333; } div.coul02,.blue,.coul02{ color:#3366CC; } div.coul02,.grey,.coul02{ color:#C0C0C0; }"; preg_match_all("/^div\.[^,{]*,[\.#](\w+)/ms", $mycss, $matches, PREG_PATTERN_ORDER, 0); ?>
and then in your $matches variable you will have something like this:
$matches[0][0] div.coul01,.red $matches[0][1] div.coul02,.blue $matches[0][2] div.coul02,.grey $matches[1][0] red $matches[1][1] blue $matches[1][2] grey
$matches[1] is what you are looking for
Example
source share