I would use variables in place of all the values you need to change, then include the variables file into the CSS file.
----- Make a script to write all your variables/values to a file from an HTML form. Include the variable file so you can see the current values. -------
<?
include 'variables.php';
if ($update == "yes") {
$text = "<?php\n";
$text .= "\$bg_color = \""."$new_bg_color"."\";\n";
$text .= "\$text_color = \""."$new_text_color"."\";\n";
$text .= "?>";
$filename = "variables.php";
$file = fopen($filename, "w");
fputs($file, $text);
fclose($file);
}
?>
<FORM ACTION='<?=$PHP_SELF; ?>' METHOD='post'>
<INPUT TYPE=hidden NAME='update' VALUE='yes'>
<INPUT TYPE=text NAME='new_bg_color' VALUE=<?=$bg_color; ?>'>
<INPUT TYPE=text NAME='new_text_color' VALUE=<?=$text_color; ?>'>
<INPUT TYPE=submit>
</FORM>
------ Your variable file would look something like this after updating ------
<?
bg_color = "FFFFFF";
$text_color = "000000";
?>
Then in your CSS file have something like this.
include 'variables.php';
.top_menu {background: #<?=$bg_color; ?>;}
.text {background: #<?=$text_color; ?>;}
This way, you can avoid REGEX totally. I hope this makes sense.