I'm trying to remove large blocks of text from a file using python. Each block of text begins with
/translation="SOMETEXT"
Ending with the second quote.
Can anyone give me some advice on how to accomplish this?
Thank you
I'm trying to remove large blocks of text from a file using python. Each block of text begins with
/translation="SOMETEXT"
Ending with the second quote.
Can anyone give me some advice on how to accomplish this?
Thank you
If performance doesn't matter, you could do something like this. Regular expressions would probably be faster, but this is simpler.
def remtxt(s,startstr,endstr):
while startstr in s:
startpos=s.index(startstr)
try:
endpos=s.index(endstr,startpos+len(startstr))+len(endstr)
except:
return
s=s[:startpos]+s[endpos:]
return s
new_string=remtxt(my_string,'/translation="','"')