I have a small python script that loops through a bunch of files and in each file apply a few regex. I would like to add a confirmation step in which the old and the new text are shown. Is there any efficient way of doing this. Right now, in a string, I am doing a .search., then a .sub within the matched text and the if the user confirms I insert the new text in the original string (by indices).
I have a small python script that loops through a bunch of files and
Share
You could use re.sub with a callback that ask the user’s confirmation:
http://docs.python.org/2/library/re.html#text-munging
which print