Hi,
my name is Luigi Zoso and I'm currently trying to automatically remove
comments from files containing Javascript code, by using jakarta-ORO's
"Util.substitute()"  API. I built a java class by following the guidelines
of substituteExample.java.
I'm experiencing some problems when I try to delete comments of the type:
/* This is a comment */
The problem is to find the correct regular expression in order to match
these comments and replace them with a blank string in the file.
 At present,  I use the following expression:
(\/+[\*]+[^\*\/]+[\*]+\/)
I put the "[^\*\/]" in order to avoid removing code between two comments,
like in this example:

/*First comment*/
Function myFunction()
{alert("I don't want to delete this code");}
/*Second comment*/

This works for simple cases, such as single comments isolated from the rest
of the code, but it fails with more complex cases such as when a "/" is
present inside the comment:

/*First comment*/
Function myFunction()
{alert("I don't want to delete this code");}
/*Second comment with / inside it */

Could anyone help me with a more useful regular expression?
Thank you
Luigi Zoso


This message is for the designated recipient only and may contain
privileged or confidential information.  If you have received it in error,
please notify the sender immediately and delete the original.  Any other
use of the email by you is prohibited.


Reply via email to