I use re
to find a word on a file and I stored it as lattice_type
Now I want to use the word stored on lattice_type
to make another regex
I tried using the name of the variable on this way
pnt_grp=re.match(r'+ lattice_type + (.*?) .*',line, re.M|re.I)
Here I look for the regex lattice_type=
and store the group(1)
in lattice_type
latt=open(cell_file,"r")
for types in latt:
line = types
latt_type = re.match(r'lattice_type = (.*)', line, re.M|re.I)
if latt_type:
lattice_type=latt_type.group(1)
Here is where I want to use the variable containing the word to find it on another file, but I got problems
pg=open(parameters,"r")
for lines in pg:
line=lines
pnt_grp=re.match(r'+ lattice_type + (.*?) .*',line, re.M|re.I)
if pnt_grp:
print(pnt_grp(1))