Replaces use of preg_replace and \e modifier (deprecated php 5.5) with preg_replace_callback. Uses class for regex callback to maintain support for php 5.2 (passing arguments to regex callback).