my $alpha = join '', ('a'..'z'); # $alpha = 'abcdefghijklmnopqrstuvwxyz' $alpha =~ s/(?<=def).*(?=uvw)//; # remove everything preceeded by the substring 'def' # and succeeded by the substring 'uvw' print $alpha; # $alpha = 'abcdefuvwxyz'