Simple JS parser to strip comments

Usage is simple – create an instance and call .strip(string) to get back the de-commented string…

It’s *intended* to be 100% effective – catching any valid comment, including:


I’ve tested it a bit against use-cases I could think of, and tried it against a few common libraries (e.g., the dev version of jQuery), and it seems fine, but I’d be interested to hear if anyone breaks it.

Source is a little longer than I like for this blog so here’s it is on github:

UPDATE 03/13/13
A commenter has created a fiddle with some test-cases that this fails to match properly: I’ll be updating as time allows to try to match these examples, and any others that anyone wants to contribute. As always, forks welcome.