Hi Everyone,
I just thought this would come in handy for someone one day, so i thought I'd share it.
public static function HighlightRegexp($pattern)
{
$str = $pattern;
$colors = array(
"/" => "red",
"(" => "green",
")" => "green",
"[" => "blue",
"]" => "blue",
"{" => "orange",
"}" => "orange"
);
$specialchars = array("?","+","*",".","|");
foreach($colors as $key => $value)
{
$str = str_replace($key, "<font color=".$value.">".$key."</font>", $str);
}
foreach($specialchars as $key => $value)
{
$str = str_replace($value, "<font color=purple><b>".$value."</b></font>", $str);
}
$str = '<div style="border: #999999 thin solid; background-color: #F6F6F6; padding: 10px;">'.$str.'</div>';
return $str;
}
Pass it a regexp patern and it will return a highlighted verson, (for visual use only) to make it more readable.
You could modify this to highlight almost anything.
Feel free to ask questions...