Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Do I understand this?

by LanX (Canon)
on Jan 16, 2013 at 00:08 UTC ( #1013473=note: print w/ replies, xml ) Need Help??


in reply to Do I understand this?

Yes, you do!

It deletes HTML-comments, even if they span multiple lines.

Anyway it's better (and less buggy) written as $var =~ s/<!--.*?-->//gs

EDIT: Please note the .*? for non-greedy now, otherwise you are deleting everything in between the first and the last HTML-comment.

see also Regex: Char-class equivalent for [^] for a recent discussion of '.' and '/s'

Cheers Rolf

UPDATE: corrected C&P typo ~=


Comment on Re: Do I understand this?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2015-07-05 06:46 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 (60 votes), past polls