in reply to Regex latest match?
This might not be terribly efficient however, if there happen to be a lot of matches. It might be better to start with a rindex:use strict; use warnings; my $start = 'start:'; my $end = 'stop:'; $_ = join '', <DATA>; @_ = m/\Q$start\E(.*?)\Q$end\E/gs; print $_[-1]; __DATA__ something start: some text stop: other text here start: again somethin +g stop: may be some text here start: and finally stop: and maybe some +thing here
pos = rindex($_, $start); m/\Q$start\E(.*?)\Q$end\E/gs; print $1;
|
|---|