develooper Front page | perl.perl5.porters | Postings from June 2014

[perl #122171] Regular expression with lookahead does not match, while it should.

Thread Previous | Thread Next
From:
James E Keenan via RT
Date:
June 24, 2014 20:52
Subject:
[perl #122171] Regular expression with lookahead does not match, while it should.
Message ID:
rt-4.0.18-11823-1403643123-1541.122171-15-0@perl.org
On Tue Jun 24 00:45:27 2014, dietmar.schindler@manroland-web.com wrote:
> This is a bug report for perl from dietmar.schindler@manroland-
> web.com,
> generated with the help of perlbug 1.40 running under perl 5.20.0.
> 
> 
> -----------------------------------------------------------------
> I observed the following bug in Perl versions 5.10.1, 5.18.2 and
> 5.20.0, while
> versions 5.6.2 and 5.8.7 behaved correctly.
> Regular expressions similar to /(?=.*P)P/ do not match certain text
> which they
> should match. Example:
>         " P" =~ /(?=.*P)P/
> yields no match, i. e.
>         print " P" =~ /(?=.*P)P/
> prints nothing instead of 1.
> --------------------------------------------------------------

I don't believe this is a bug in Perl 5.

According to 'perldoc perlre' in blead:  "(?=pattern)" is used as "A zero-width positive look-ahead assertion."

If we are to look ahead, we have to have something in the pattern *from which we are looking ahead*.  I don't see anything like that in your pattern.  Did you perhaps want a positive look-behind pattern "(?<=pattern)"?

Thank you very much.
Jim Keenan

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=122171

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About