use strict;
my $str = 'Rough work iconoclasm but the only way to get the truth. Oliver Wendell Holmes
Rough work, iconoclasm, but the only way to get the truth. Oliver Wendell Holmes
Rule No. 1: Never lose money. Rule No. 2: Never forget rule No. 1. Warren Buffett
Rule No.1: Never lose money. Rule No.2: Never forget rule No.1. Warren Buffett
Self-esteem isn\'t everything, it\'s just that there\'s nothing without it. Gloria Steinem
Self-esteem isn\'t everything it\'s just that there\'s nothing without it. Gloria Steinem
You said she\'s a senior? Babe we\'re all crazy.
You said, she\'s a senior! Babe we\'re ALL crazy.
You said, she\'s a senior? Babe we\'re ALL crazy!
a
a a
a a a
a
a b
a b c
a b
a';
my $regex = qr/^(?>[^\w\n]*(\w++)(?=.*\R(\2?+[^\w\n]*\1\b)))+[^\w\n]*\R(?=\2[^\w\n]*$)/mip;
my $subst = '';
my $result = $str =~ s/$regex/$subst/rg;
print "The result of the substitution is' $result\n";
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html