Regex question. I have something similar to this:
use strict;
my $lines = "";
while(<DATA>)
{
$lines .= $_;
}
$lines =~ s/^s.*?e p$//msg;
print $lines;
__DATA__
Random String
s
erartt
e p
s
foo
e f
blah blah
s
adflkja
e p
End of file
I want to get this:
Random String
s
foo
e f
blah blah
End of file
as the expression is non-greedy, but instead I get nothing. I realize this is because it encounters the s and matches the least to the next e p. So I can evaluate each match and deal with it there, but I was wondering if there was a better way to accomplish this.
Update: fixed the data space and added more information to the testcase.
==
Kwyjibo. A big, dumb, balding North American ape. With no chin.