Hello,
I need a regex that will take a block of text and highlight HTML syntax.
Text will be one color, tags will have another and attribute values will have another.
I don't need to highlight the text, and these are the two lines I use to highlight now:
Code:
$text = preg_replace("/<(.*)>/","<span style='color:#000099;font-family:monospace;background-color:#CCCCCC'><\\1></span>",$text);
$text = preg_replace("/<(.*)("|\')(.*)("|\')(.*)>/","<\\1<span style='color:#0000FF;font-family:monospace;background-color:#CCCCCC;'>\\2\\3\\4</span>\\5>",$text);
However they're very buggy. It only highlights the last attribute value of each line, and it highlights all the text in between tags as if they were tags as well.
Any ideas to improve these?
-Snib -
http://www.snibworks.com
Where will you be in 100 years?