Welcome to the Monastery | |
PerlMonks |
Re: Finding repeat sequences. (only mostly regex)by tye (Sage) |
on Jun 18, 2013 at 19:40 UTC ( [id://1039635]=note: print w/replies, xml ) | Need Help?? |
I assume that the pattern must repeat at least twice, otherwise, the full string is always the longest answer. A simple regex can get a good guess and tell you when that guess has failed in such a way that each subsequent guess will be more than twice as long as the previous guess so the regex doesn't have to be run very many times:
You likely can optimize this by copying less stuff, of course. (Update: Well, I didn't get very rigorous in proving to myself that $pattern.$repeat is always too short. But I believe that to be the case. One should validate or refute that assumption before deciding whether to use this.) - tye
In Section
Seekers of Perl Wisdom
|
|