I'm looking to change some regex I'm using to cater for HTML comment tags instead of CSS.
I've built a preg replace function that can edit between comments in a stylesheet like so:
$find = array();
$find[0] = "/(\/\*bgColor\*\/).*?(\/\*\/bgColor\*\/)/i";
$find[1] = "/(\/\*titleColor\*\/).*?(\/\*\/titleColor\*\/)/i";
$replace = array();
$replace[0] = "\\1 background-color: $bgColor; \\2";
$replace[1] = "\\1 color: $titleColor; \\2";
$result = preg_replace($find, $replace, $file);
The way this works is demonstrated below:
/*titleColor*/ color: #000; /*/titleColor*/
Any content between the two CSS tags will be replaced.
I'm looking to replicate this idea but with html like so:
<!--titleColor--> content_to_replace <!--/titleColor-->
What do I need to change in the preg_replace in order for this to work correctly with html comment tags?