# [Python 3], 98 bytes <!-- language-all: lang-python --> lambda s,e=enumerate:[s[i-n:i]for i,n in e([9]+s)if all(m+~j for j,m in e(s[i-n:i-1]))>0<n<=i] [Try it online!][TIO-k1pnw73r] Takes the input as a list and maps it to a list of lists where each item is a sublist of length `n` ending with item `n` for each item. Then it is filtered so that no list contains other valid length terminators. -4 bytes thanks to Jonathan Frech [Python 3]: https://docs.python.org/3/ [TIO-k1pnw73r]: https://tio.run/##VVBBboMwELz3FXsExZG8GAcchX6EcqCqUR2BEwE59NKv012bIllisT0zOzva58/6/fBqG5qPbeynz68eFmEb61@TnfvVXtuldWd/dd3wmMEJD86DzVrTnZbcDdCPYzadfu/A9F1Mkd57ztjl@bu8@Vvjuu05O79mQ9ZWAi4CtIBSgBJQCGDd28EbKaCmqmQCY5Cq0KZTRpJaBjp@x7NMdMlDk82lDobHNREwSIVISQsKXHAszQBJDZ2SfvWuKgmrmCzIzxChOCsBhgjkxOSgyAGJVzwzOJk4nE9uRKQuzVYmVvk/jy@aNmCQAfLiJapor3lUxbiKYWrcM3BitS9y@wM "Python 3 – Try It Online"