Refine diff substitution patterns.