I would like to know if there exists a direct way of knowing whether a substring given is present within a string strictly inbetween (i.e) not startswith and not endswith but somewhere contained within the string.
substring = "trees"
input1 = "sketchthetreesanddaffodils"
input2 = "treesaregreen"
input3 = "greentrees"
input4 = "greentreesareoftengreenertrees"
output1 = True
output2 = False # 'trees' appearing at the beginning though
output3 = False # 'trees' appearing at the end though
output4 = True # 'trees' appear in middle, regardless of the one in the end
Expected operation
str.containsinmiddle()
#Something similar to str.startswith(), str.endswith()