ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dun...@sapio.co.uk (Duncan Harris)
Subject Re: JavaScript comment stripping Task
Date Thu, 01 Jan 1970 00:00:00 GMT
holtdl@yahoo.com (Diane Holt) wrote:

> --- Duncan Harris <duncan@sapio.co.uk> wrote:
> > I've just knocked up an Ant Task to strip comments from JavaScript
> > files. Useful in web apps so you can comment to your hearts delight
> > without using up runtime bandwidth.
> > 
> > Would this be useful to others, or is there some component out there
> > that already does this which I missed in my quick search?
> 
> I should think <replaceregexp> (available in the nightlys, until 1.5 comes
> out) could do that.

OK I'll take a look. Although it requires a couple of passes and the regexp
for the main pass is fairly hairy. Substitution would be something like:

(?ms)("(?:\\"|[^"\r\n])*"|'(?:\\'|[^'\r\n])*')|//.*?$|/\*.*?\*/

for $1

Then you need another pass to get rid of blank lines
and then another pass if you want to rid excess space.

How stable is the 1.5 alpha nightly?
I just tried to get the latest and it didn't build in SunJDK 1.3.1.

Duncan Harris
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hartford, Cheshire, U.K., Tel: 07968 060418

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message