modify regexp on replacement to fix #240