Use preg_replace_callback rather than the /e option, which is not supported on GAE.