extract_replacement_rules function

Extract replacement rules