I'm looking to match many files against some common templates, and extract the differences. I'd like suggestions on the best way to do this. For example:
Template A:
<1000 text lines that have to match>
a=?
b=2
c=3
d=?
e=5
f=6
<more text>
Template B:
<1000 different text lines that have to match>
h=20
i=21
j=?
<more text>
k=22
l=?
m=24
<more text>
If I passed in file C:
<1000 text lines that match A>
a=500
b=2
c=3
d=600
e=5
f=6
<more text>
I'd like an easy way to say this matches template A, and extract 'a=500', 'd=600'.
I could match these with a regex, but the files are rather large, and building that regex would be a pain.
I've also tried difflib, but parsing the opcodes and extracting the differences doesn't seem optimal.
Anyone have a better suggestion?