my $line = 'abc clothes doing shopping at the .mall abc something doing shopping at the .mallabc'; my ($before, $between, $after) = /(.*?.clothes|.something)(.*?)(\.mall.*)/; print "Matched: '$before', '$after'\n";