my $string = "blah text1 you mean something like this? text2 blah blah"; if ($string =~ m/text1(.*?)text2/) { print $1; }