Jester has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I have a small problem that I can't seem to solve. I need to find duplicate text within a paragraph. Let's say my text looks like this:
"The cat jumped over the dog. Smart cat! He jumped over the dog. The cat jumped over the dog."
I don't need to find all 3 repetitions of the word cat. However, I need to find the longest repeated sentence: 'The cat jumped over the dog'.
I was thinking of a lookahead, and tried something like
m/([\w\s\.]?){?=$1)/g;
which kinda fails miserably.
Any help much appreciated!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Finding duplicate text in a paragraph
by davido (Cardinal) on Aug 20, 2012 at 20:57 UTC | |
by Jester (Novice) on Aug 20, 2012 at 21:00 UTC | |
|
Re: Finding duplicate text in a paragraph
by Kenosis (Priest) on Aug 20, 2012 at 20:20 UTC | |
by Jester (Novice) on Aug 20, 2012 at 20:43 UTC | |
by Kenosis (Priest) on Aug 20, 2012 at 20:46 UTC | |
|
Re: Finding duplicate text in a paragraph
by BrowserUk (Patriarch) on Aug 20, 2012 at 20:59 UTC | |
|
Re: Finding duplicate text in a paragraph
by hbm (Hermit) on Aug 20, 2012 at 19:52 UTC | |
by Jester (Novice) on Aug 20, 2012 at 20:40 UTC | |
by Jester (Novice) on Aug 20, 2012 at 20:45 UTC |