There has been research on this in the field of text editing. There, the idea is to have the user edit a semi-structured text and to replicate the changes to similar portions of the text (with the appropriate transformations).
The general idea is to generate candidate patterns and rank/dismiss them based on user input and heuristics.
See for example this paper for a nice overview.