ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig Berry" <>
Subject RE: Removing whitespace in the code
Date Tue, 25 Feb 2003 23:40:13 GMT
> Here is an equivalent expression (PERL Golf):
> perl -p0e 's/\s\s+/ /sg' < src_file.html > dst_file.html

You can knock one off the perl-golf score by omitting the /s qualifier on the substitution;
/s only changes the interpretation of the . match to include \n, and your pattern includes
no dots.

However, you can really score big (small?) by doing this instead, if you're actually only
interested in spaces rather than all white space:

  perl -p0e 'y/ //s' <src_file.html >dst_file.html

> Since the code reduces the entire file to one line, either of these solutions are
> not good for JSP files with scriptlets (line comments suddenly make portions of
> your code commented out.)

Which is one good reason for only going after spaces (and possibly tabs) rather than all white

Craig Berry
Principal Architect and Technical Manager
(310) 566-7546

View raw message