Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Matching and replacing the minimum string from the tail of the regex

by abitkin (Monk)
on Aug 09, 2007 at 14:13 UTC ( [id://631561]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Matching and replacing the minimum string from the tail of the regex
in thread Matching and replacing the minimum string from the tail of the regex

For some reason, I had trouble with your code. Instead I turned the problem on it's head.
use strict; my $lines = do{ local $/; <DATA> }; # reverse the order of the lines so that the RE matches the # last part of the region first my $reversetext = join("\n", reverse(split("\n",$lines))); $reversetext =~ s/^[^\n]*e p.*?s[^\n]*\n//msg; # put the lines in normal order again $lines = join("\n",reverse(split("\n", $reversetext))); print $lines; __DATA__ Random String s erartt e p s foo e f blah blah s adflkja wibble wobble e p End of file

==
Kwyjibo. A big, dumb, balding North American ape. With no chin.
  • Comment on Re^3: Matching and replacing the minimum string from the tail of the regex
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://631561]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-16 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found