perform substitutions on the original text based on set of rules