pattern-based substitution