Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I'm sorry I can only unrecommend JavaScript::Squish []. It produces non-working JS for very simple input.

    These regexes worked for me:

            $output =~ s(^\s*//.*$)()gm; # c++ style comments on line without code
        $output =~ s(^\s+)()gm;      # leading white space
        my $end = "\s*[\r\n]+";
        $output =~ s(;$end)(;)g;     # no newline after ;
        $output =~ s({$end)({)g;     # no newline after {

    • Interesting, that's more detailed than my own conservative attempt:

      $in =~ s{^/\*.*?\*/}{}gxms;
      $in =~ s{^//.*?$}{}gxms;
      $in =~ s{^[ ]+}{}gxms;
      $in =~ s{\n+}{\n}gxms;
      I deliberately only strip from beginning or ends of line to reduce risk of stripping from inside quotes. The above already chops enough that I can feel comfortable indenting and commenting my Javascript code thoroughly.