Codice PHP:
$stringa preg_replace("/(color=#)([a-fA-F0-9]{6})/""style=\"color: $2\""$testo);