my $test='deferred gross profit is blah blah blah.'; if($test=~m/(\bdeferred|unrealized)(.*)(\.)/) { print "matched $1 and the rest is $2"; }