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

Re: Regex to strip comments

by GrandFather (Sage)
on Oct 01, 2012 at 00:36 UTC ( #996560=note: print w/replies, xml ) Need Help??


in reply to Regex to strip comments

In essence you can't do it with a regex without constraining yourself to the simpler cases. You need to parse a fair chunk of the language to be able to distinguish between comments and things that look like comments in other contexts, such as in strings as you have noted already. However dealing with nested comments is tough on regexen and is the real killer.

Note that the regex you give won't work as expected across multiple lines because . doesn't match newline characters unless you use the /s option.

True laziness is hard work

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://996560]
help
Chatterbox?
[Discipulus]: Eternal City?
[Corion]: Hmm - my Italian isn't that great - I assume this is more an accident and less an art project, right?
[Discipulus]: yes we are falling down

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2017-02-28 10:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (399 votes). Check out past polls.