Your message dated Sun, 12 Aug 2012 17:27:49 +0100
with message-id <[email protected]>
and subject line Re: Bug#681849: perl: regex negative lookbehind does not work 
before $
has caused the Debian Bug report #681849,
regarding perl: regex negative lookbehind does not work before $
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
681849: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=681849
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: perl
Version: 5.14.2-6
Severity: normal

Dear Maintainer,

The negative look-behind assertion does not work correctly before $ (the
end-of-line assertion).

I expect to be able to say "match lines that do not end in bar"
using the regex /(?<!bar)$/ .  However this does not work:

% (echo foo; echo bar; echo foobaz) | perl -ne 'print if(/(?<!bar)$/)'
foo
bar
foobaz
%

It should not have printed "bar" above.  

A similar pattern using /^(?!bar)/ works to say "lines that do not
start with bar", and negative look-behind works before a string:

# negative lookahead
% (echo foo; echo bar; echo foobaz) | perl -ne 'print if(/^(?!foo)/)'
bar
%

# negative lookbehind before string
% (echo foo; echo bar; echo foobaz) | sed 's/$/x/g' | \
         perl -ne 'print if(/(?<!bar)x$/)'
foox
foobazx
%

I found a workaround that may shed light on the root cause of the
problem.  Normally /$/ matches the end of a string or the line-ending
character at the end of a <> string, and regex behavior with $ is not
changed by chomp()ing the line-ending-character away.  But in this case,
there is a difference.  If I "chomp;" before matching, the negative
look-behind assertion works correctly:

% (echo foo; echo bar; echo foobaz) | perl -ne 'chomp; print if(/(?<!bar)$/)'
foofoobaz
%

Note that it did not print "bar" above, correctly implementing the behavior
documented in perlre(1).


-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.4.0-rc4-00095-g95f7147 (SMP w/4 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages perl depends on:
ii  libbz2-1.0    1.0.6-1
ii  libc6         2.13-26
ii  libdb5.1      5.1.29-1
ii  libgdbm3      1.8.3-10
ii  perl-base     5.14.2-6
ii  perl-modules  5.14.2-6
ii  zlib1g        1:1.2.3.4.dfsg-3

Versions of packages perl recommends:
ii  netbase  4.47

Versions of packages perl suggests:
ii  libterm-readline-gnu-perl | libterm-readline-perl-perl  <none>
ii  make                                                    3.81-8.1
ii  perl-doc                                                5.14.2-6

-- no debconf information

--- End Message ---
--- Begin Message ---
On Sat, Aug 11, 2012 at 01:00:46PM +0100, Dominic Hargreaves wrote:
> On Mon, Jul 16, 2012 at 11:06:05PM -0700, Andy Isaacson wrote:
> > The negative look-behind assertion does not work correctly before $ (the
> > end-of-line assertion).
> > 
> > I expect to be able to say "match lines that do not end in bar"
> > using the regex /(?<!bar)$/ .  However this does not work:
> > 
> > % (echo foo; echo bar; echo foobaz) | perl -ne 'print if(/(?<!bar)$/)'
> > foo
> > bar
> > foobaz
> > %
> > 
> > It should not have printed "bar" above.  
> 
> Hi,
> 
> As this isn't a Debian specific issue I've forwarded this upstream:
> 
> https://rt.perl.org/rt3/Ticket/Display.html?id=114452
> 
> I've also added you as a requestor on that ticket (let me know if
> that's not what you want).

As upstream have replied stating that this is behaving as expected, I'm
going to close this bug.

Thanks,
Dominic.

-- 
Dominic Hargreaves | http://www.larted.org.uk/~dom/
PGP key 5178E2A5 from the.earth.li (keyserver,web,email)

--- End Message ---

Reply via email to