Is it possible from go/golang to just delete everything contained in between two strings? I have a input.txt file which has the following structure:
#start-kiwi
this text
is important
#end-kiwi
#start-banana
this text
needs to be
completely removed
#end-banana
#start-orange
this text
is also important
#end-orange
From go code I am trying to delete everything in between the markers #start-banana and #end-banana (included both) so the desired result would be:
#start-kiwi
this text
is important
#end-kiwi
#start-orange
this text
is also important
#end-orange
I am using go 1.19 and I have already tried these methods:
string.Contains(strings.Replace(input.txt, "#start-banana", "")
string.Contains(strings.Replace(input.txt, "#end-banana", "")
But it seems like it is not working all right. Is there any preferred method of achieving this? RegEx? With strings library?
Thanks in advance.