Yes, just utilize \1
in a regex to indicate a repeated matched pattern. I intentionally limitted this regex to only match 2-4 word phrases to limit how hard it'd have to work:
#!usr/bin/perl
use strict;
use warnings;
while (<DATA>) {
if (my @phrases = /\b(\S+(?:\s+\S+){1,3})\s+\1/g) {
print "$_\n" for @phrases;
}
}
__DATA__
The great eagle flied high flied high.
The call was done at night was done at night.
Outputs
flied high
was done at night