Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by hv (Parson)
on Aug 11, 2007 at 21:34 UTC ( #631977=note: print w/replies, xml ) Need Help??


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

I'm not sure if there is a better way, but to me the obvious approach is to accept 'start' followed by '(not start)*' followed by 'end':

my $lines = do { local $/; <DATA> }; $lines =~ s{ ^ s \n # start line (?: ^ (?! s \n ) .* \n )* # body excluding new start line ^ e\ p $ # end line }{}xmg; print $lines;

Note that this does more work than the original failing substitution, so you can expect it to be slower.

I'm assuming that the start of a test is "an 's' followed by a newline", and on that assumption being a bit stricter than your original example about matching that.

Hope this helps,

Hugo

  • Comment on Re: 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://631977]
help
Chatterbox?
[marinersk]: :: ducking ::
[choroba]: because, someone renamed the method, but didn't notice it was used in the test, as the test was skipped
[marinersk]: Well, if the method doesn't exist, it would be hard to pass the test.
[choroba]: later, someone removed the new method, as all its usage places were safe, but didn't notice the test still used the old name
[choroba]: fortunately, it wasn't that hard to replace the method and fix a few remaining failures due to the changes we did to the codebase over the years
[marinersk]: choroba Sounds like a process improvement opportunity; tests may not all need to be run, but they should all be compiled with perl -c before check-in/promotion happens.
[choroba]: so, now I have the test, so I can start making changes in the code. Back to the original ticket, yay!
[marinersk]: I definitely love it when my $current_taask=& taskPop(); if ($current_task eq $original_task) { } is true.
[marinersk]: s/taask/task/g;

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2017-05-25 15:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?