Fixing deprecated warning for preg_replace function and PHP 5.5

When working with PHP 5.5 I was receiving some deprecated warnings about the "preg_replace" function. As suggested I rewrote the code to use the "preg_replace_callback" to remove the deprecated warning.