I would like to loop on every lines from a .txt file and then use re.sub
method from Python in order to change some contents if there is a specific pattern matcing in this line.
But how can I do that for two different pattern in the same file ?
For example, here's my code :
file = open(path, 'r')
output = open(temporary_path, 'w')
for line in file:
out = re.sub("patternToChange", "patternToWrite", line) #Here I would like to also do the same trick with "patternToChange2 and patternToWrite2 also in the same file
output .write(out)
Do you have any ideas ?