I'm trying to reliably strip out Javascript multi-line and single-line comments in Java or Scala. Even if it requires running an external program, that would be OK (but not ideal). There must be some library or tool to do this. I've looked at this post:
http://james.padolsey.com/javascript/removing-comments-in-javascript/
and converted it to Scala. But his logic is broken in a few different ways. One problem is that it doesn't properly tell the difference between division and the start of a regex. It also doesn't handle escape sequences in all situations. I've been trying to fix this code, but its tricky - especially telling the difference between regex and division.
I don't want to re-invent the wheel here, and I don't want to build a freaking Javascript parser. Any ideas?

//for single-line and/*...*/for multi-line, right? Using a sub-string search function for these three specific patterns may be your best bet.../** etc etc**/and// etc etc \n