using regex for rules of replacement