Let's say there are two input files as below:
input1.txt (only composed of hstep3_*)
hstep3_num00 = a5;
hstep3_num01 = 3b;
hstep3_num02 = 4f;
hstep3_num03 = 27;
input2.txt ( the letters inside brackets are some random characters split by ,)
some random strings that are not 'hstep' form
...
match hstep1_num00 = {eau,t,nb,v,d}; // MATCH
match hstep1_num01 = {c,bul,kv,e}; // MATCH
...
match hstep3_num00 = {u_ku,b,ntv,q}; // MATCH
match hstep3_num01 = {qq,rask,cb_p}; // MATCH
match hstep3_num02 = {c,a,ha,w,ykl}; // MATCH
match hstep3_num03 = {p,gu,enb_q_b,z,d}; // MATCH
...
some random strings that are not 'hstep' form
and What I want to do is to sort out all the left hand side of equation from input1.txt, and match the corresponding bracket and value from input2.txt.
So, the final output.txt looks as follows:
output.txt
{u_ku,b,ntv,q} = a5;
{qq,rask,cb_p} = 3b;
{c,a,ha,w,ykl} = 4f;
{p,gu,enb_q_b,z,d} = 27;
In order to do so by python, I've thought about readlines.split().
Also, since the number of Characters inside bracket are not always same by lines, I thought I have to use regular expressions to limit the range inside {}
but It doesn't work as I expected...
Anybody give me any solutions or guidelines for this?
Any help would be much appreciated.. thanks!
The code below is not optimized, but it's so OP understands the processes involved a bit better
output.txtfile contents: