Parsing a random string looking for repeating sequences using Java and Regex.
Consider strings:
aaabbaaacccbb
I\'d like to find a regular expression
You could disregard overlap.
// overlapped 1 or more chars
(?=(\w{1,}).*\1)
// overlapped 2 or more chars
(?=(\w{2,}).*\1)
// overlapped 3 or more chars, etc ..
(?=(\w{3,}).*\1)
Or, you could consume (non-overlapped) ..
// 1 or more chars
(?=(\w{1,}).*\1) \1
// 2 or more chars
(?=(\w{2,}).*\1) \1
// 3 or more chars, etc ..
(?=(\w{3,}).*\1) \1