I have file
Mod top (o i)
In a
Op a
End
Mod mid (o i)
In a
Op a
End
Mod bottom (o i)
In a
Op a
End
I want to replace “a” with “z” only in mid.
with open(‘data.txt’,'r') as file:
read_lines = file.readlines()
for line in read_lines:
print line.replace(string_to_be_identified,string_to_be_replace)
file.close()
I tried to match using regex and then replace but it will repalce all lines after it but i want only in that “mid”
Expected
Mod top (o i)
In a
Op a
End
Mod mid (o i)
In z
Op z
End
Mod bottom (o i)
In a
Op a
End