On Nov 14, Michael G Schwern said: >On Wed, Nov 14, 2001 at 09:03:21PM -0500, Jeff 'japhy' Pinyan wrote: >> On Nov 14, Michael G Schwern said: >> >> > 1) Strips all comment-only lines from a Perl program (ie. /^\s*#/) >> > except those which are C pre-processor commands. (It's not >> > necessary to worry about if you're inside a string or not). >> >> perl -pe 's/^\s*#\s*(?!include|define|if(n?def)?|el(se|if)|undef|endif).*//s' > >Ahh, you fell victim to the same problem I did. Because of the >look-ahead, that skips. > ># define FOO 1
Feh. perl -pe 's/^\s*#(?>\s*)(?!include|define|if(n?def)?|el(se|if)|undef|endif).*//s' And no, I don't want to use /m here. I want /s, because /s makes . match a newline, which means .* slurps up to the end of the line. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
