use strict; use warnings; my $str = "Some rubbish before TEST and the good stuff afterwards"; $str =~ s/^.*?(?=TEST)//; print $str;