dodgy implementation of regex replace also for CGI