in reply to Regex AND NOT with zero-width negative lookahead assertion
I think this might do what you want.
use strict; use warnings; use Test::More tests => 1; my $want = <<'EOT'; if(/ok .*$/) { if(m/a good match/( { $string =~ s/[a-f]//g; # but print this line ( $string ) = ( $string =~ /(show this)/)); /but show\/this, too/ EOT my $have = ''; while (<DATA>) { $have .= $_ if m~^(?!#)[^/]*/[^/]+(\\/|/(?!\w+/?))~; } is $have, $want; __DATA__ #!/usr/bin/perl foo bar foo/bar /src/bin/oops/otehnoes if(/ok .*$/) { print "not OK\n"; } # skip a comment if(m/a good match/( { print "not ok\n"; } # do not /print/ this line either $string =~ s/[a-f]//g; # but print this line ( $string ) = ( $string =~ /(show this)/)); /but show\/this, too/ my $butdontprintthis = "/var/cache/dictionaries-common";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex AND NOT with zero-width negative lookahead assertion
by mldvx4 (Hermit) on Mar 25, 2020 at 13:34 UTC | |
by hippo (Archbishop) on Mar 25, 2020 at 13:43 UTC | |
by Your Mother (Archbishop) on Mar 25, 2020 at 14:04 UTC | |
by AnomalousMonk (Archbishop) on Mar 26, 2020 at 03:41 UTC |