#!/usr/bin/perl -w use strict; my $myPattern = "(\\w+)(\\s+\\1\\b)"; my $myTestString = "Paris in the the Spring Spring."; print "The original string was '$myTestString'.\n"; $myTestString =~ s/$myPattern/$1/g; print "The captured group was: '$1'.\n"; print "Any doubled word has now been removed.\n"; print "The string is now '$myTestString'.\n";