in reply to Regex get Text between two strings with colon

The following works, but requires you to slurp the entire file into memory. If the file is large that might not be the best approach, I talked about a different, line-by-line approach in the recent thread about a similar topic, Multi Line Regex Matches... - basically, you'd need to keep the lines between the "start" and "end" markers in a buffer, probably an array. In regards to the following, see the documentation of the anchors ^ and $, as well as the modifiers /s, /m, and /x, in perlretut and perlre.

my $data = do { open my $fh, '<', $fn or die $!; local $/; <$fh> }; my ($test) = $data=~m{ ^\w+:\n (.+?) (?: ^\w+:$ | \z ) }msx;