Fix replace regex to include ESC characters