Perl: the Markov chain saw | |
PerlMonks |
Re: Re: Re: finding longest common substringby davido (Cardinal) |
on Nov 20, 2003 at 06:37 UTC ( [id://308524]=note: print w/replies, xml ) | Need Help?? |
:) Ok, now that I better understand what you're asking, here's my regex solution. I think that this improves upon some other methods by starting with the longest and working down to the shortest, (quitting as soon as a match is found).
Ob-Update: This assumes the substrings don't overlap. And I've tinkered with the code to make it keep track of what the original substrings looked like. In so doing, I used the | character as a delimiter, which means it shouldn't appear in the original substrings. Thanks danger for the polite nudge. ;)
Dave "If I had my life to live over again, I'd be a plumber." -- Albert Einstein
In Section
Seekers of Perl Wisdom
|
|