Fix problem with malformed URLs generated by the regexp replacement