Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 ( #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
Node Status?
node history
Node Type: note [id://631561]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2020-05-31 14:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (173 votes). Check out past polls.

    Notices?