finding repeating patterns
Dar Scott
dsc at swcp.com
Sat Aug 26 17:36:39 EDT 2006
On Aug 26, 2006, at 3:17 PM, jbv wrote:
> Does anyone have (or know of) an algorithm to find repeating
> patterns of characters in a string ?
This brute-force method came to my mind. Decide on a min and max
length of patterns. Try all possible substrings. (Outer loop is
start position, inner loop is end char based on min & max length.
With each one check in an array. If not there put 1 otherwise
increment. Look for counts greater than 1.
If the repeating pattern must come right after the starting pattern,
then this does not apply. In that case, just look for the repeats of
the substring after the trial string. The problem is that "xaxaxaxa"
would be counted as a repeating of "xa" and a repeating of "xaxa".
Dar Scott
More information about the use-livecode
mailing list