in reply to Matching and replacing the minimum string from the tail of the regex

Don't tell us what you think the code does. Tell us what you want to achieve and why.

You've told us what output you expect for a given input, but not how the output is relate to the input. We can't tell that from your code because your code doesn't do what you want, nor even what you describe! The actual output is:

s foo e f s adflkja

Update:

It may be that you want something like:

use warnings; use strict; my $lines = ""; while (<DATA>) { $lines .= $_; } my @wanted = $lines =~ m/^(s(?:(?!e p$).)*e [^p]$)/msg; print @wanted; __DATA__ s erartt e p s foo e f s adflkja

Prints:

s foo e f

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Matching and replacing the minimum string from the tail of the regex
by abitkin (Monk) on Aug 08, 2007 at 23:16 UTC
    My apologizes, I missed the final line of the data space. What I'm trying to do is eliminate pass messages from a build log while keeping all the failure text. Each test has a start and end, but some data can be shown after a failure. I will update the code to reflect this. That said, I only want to eliminate items between the start (s) and the end which passed (e p).

    ==
    Kwyjibo. A big, dumb, balding North American ape. With no chin.