Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: I'm looking for a one-liner filter 'twixt two regexes

by thpfft (Chaplain)
on Sep 05, 2002 at 11:25 UTC ( [id://195335]=note: print w/replies, xml ) Need Help??


in reply to I'm looking for a one-liner filter 'twixt two regexes

perhaps I'm reading this too simply, and you mean something more complex by 'between two regexes', but it sounds like you just want:

perl -pi.bak -e "s/start(.*?)stop/$1/s" *.html

where 'start' and 'stop' are the opening and closing matches, and with a g modifier as well if you want to replace more than once in each file.

update: hold on, that's stupid. sorry. you want to replace the whole file with the match, don't you, or capture that text somewhere else? d'uh. please ignore.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-19 20:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found