In my syntax highlighter, I use regex to parse different terms. Below is how I parse PHP classes:
foreach ( PHP::$Classes as $class )
$code = preg_replace( "/\b{$class}\b/", $this->_getHtmlCode( $class, PHP::$Colors['class'] ), $code );
Now, just ignore the PHP class and the _getHtmlCode function. The regex, "/\b{$class}\b/"
, matches names such as count
. If I make a variable named $count
, it matches that was well.
How can I look for class names that are not preceded by a $
?