$ perl -Mstrict -Mwarnings -le ' my $str = q{This is a test of a regex to remove the words "a", "an", and "the" from a sentence.}; print q{Before: }, $c; $c =~ s/\b(an?|the)\b/gimsx; print q{After: }; ' This is a test of a regex to remove the words "a", "an", and "the" from a sentence. This is test of regex to remove words "", "", and "" from sentence.