Looking for 'fredfre' in 'fredfrefredfr'
tye found 'fredfrefred'; excluded from further consideration
Looks like you changed your definition of your desired results, so it was silly to use a "solution" tailored to a different definition.
This particular example matches my original speculation of what made sense, which means you might want to try my original solution. Though, I didn't wade through everything trying to find the various redefinitions of what was desired (besides the ones given in reply to my nodes) and then sort them chronologically in order to figure out what the new requirements actually are.