my $String = "hello I went to the store yesterday and the day after and the day after"; if ($String =~ m{yesterday .+? after}) { print $&; } #### my $String = "hello I went to the store yesterday and the day after and the day after"; if ($String =~ m{(yesterday .+? after)}) { print $1; }