Replaced preg_replace with preg_replace_callback

In PHP5.5 using the \e modifier causes an DEPRECATED warning to be emitted.
This PR solves it, although I'm not to happy that we need to add the extra preg_replace.
To be fair: I just copied this from the Symfony HttpKernel.