in reply to Finding duplicate text in a paragraph
Something like this?
use strict; use warnings; my $text = 'The cat jumped over the dog. Smart cat! He jumped over the + dog. The cat jumped over the dog. Smart cat!'; my %seen; my $longest = ''; while ($text =~ /\s*(.+?[!?.])/g) { $longest = $1 if $seen{$1}++ && length $1 > length $longest; } print $longest,$/;
Prints:
The cat jumped over the dog.
But it's a whole other challenge if you mean "phrase" and not (terminated) sentence.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Finding duplicate text in a paragraph
by Jester (Novice) on Aug 20, 2012 at 20:40 UTC | |
Re^2: Finding duplicate text in a paragraph
by Jester (Novice) on Aug 20, 2012 at 20:45 UTC |
In Section
Seekers of Perl Wisdom