Fixing bad regex substitution