Modified REGEX selection and replacment to be more resilant