Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: mutiple-line regexes?

by Arien (Pilgrim)
on Aug 19, 2002 at 07:33 UTC ( [id://191104]=note: print w/replies, xml ) Need Help??


in reply to Re: mutiple-line regexes?
in thread mutiple-line regexes?

Instead of using a multine regex, you could consider looping over the lines in turn and removing every six lines where there's a match on the fourth.

I think the code is pretty self-explanatory (@lines contains your file):

my $i = 3; # from line 4 ... while ($i < @lines - 2) { # ... until last but 3 if ($lines[$i] =~ m!<MYTAG></MYTAG>!) { splice(@lines, $i - 3, 6); # kill 6 lines from $i - 3 } else { $i++; } }

— Arien

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2025-02-07 04:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (94 votes). Check out past polls.