Build URI using preg_replace_callback

http://dev.kohanaframework.org/issues/4630