Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Replacing text between two html comments

by mojotoad (Monsignor)
on Jul 28, 2010 at 01:59 UTC ( #851647=note: print w/ replies, xml ) Need Help??


in reply to Replacing text between two html comments

You want to add /s as an option on your regular expression, thereby treating the whole string as a single line. Furthermore, as you have it currently, you're also zapping your delineators without replacing them. Maybe capture them as well and include their buck-whaps ($1, $3) in the replacement expression.

You're probably okay with this as long as you can reasonably guarantee that your comment tokens are unique within any given document. Otherwise use a real parser, such as HTML::Parser. Or use a template system like Text::Template.

Cheers,
Matt


Comment on Re: Replacing text between two html comments

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (19)
As of 2015-07-31 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (281 votes), past polls