Regex working down from max pattern len solution in Clear category for Double Substring by kkkkk
""" Return length of longest non-overlapping repeating substring """
line_len = len(line)
# Search for repeated substrings by starting with the largest
# possible pattern length, which will be no more than half of the
# line length, and working down to a pattern length of 1.
for pattern_len in range(line_len // 2, 0, -1):
# Given a pattern length, search for a match starting from the
# first position in the string to the last possible index,
# which is the line length minus the pattern length.
for idx in range((line_len - pattern_len) + 1):
# The pattern used in the regex starts from the current index
# to the length of the pattern. The search area starts at the
# current index.
Aug. 24, 2017