Perl does not state that `Variable length lookbehind is not implemented`

I basically make a word type statement. I want to do a test if I’m [abc]not far behind, and if [abc]ahead and vice versa.

So, I tried to do a test for this and do the negation as follows:

#!/usr/bin/perl
($_) = "abcdef" =~
/
((?&BB).*)
|
  (?!)
  (?<W>[abc])
  (?<NW>[^abc])
  (?<BB>
     (?<=(?&W))(?=(?&NW))
    |(?<=(?&NW))(?=(?&W))
  )
/x;
print;

What does not work. However, if I do this:

#!/usr/bin/perl
($_) = "abcdef" =~
/
  ((?&BB).*)
| (?!)
  (?<W>[abc])
  (?<NW>[^abc])
  (?<BB>
      (?<=[abc])(?=[^abc])
    | (?<=[^abc])(?=[abc])
  )
/x;
print;

This is true. What's going on here? Where does the variable length look like?

FYI, I know what the message means. I would like to know why perl thinks that the named group has a variable length and how do I make it stop thinking about it? This seems like a mistake to me. Does anyone else agree?

Using Versions:

This is perl 5, version 14, subversion 4 (v5.14.4) built for cygwin-thread-multi
This is perl 5, version 16, subversion 2 (v5.16.2) built for i686-linux

EDIT

So, I found a job sufficient.

#!/usr/bin/perl
$chars = qr/[abc]/;
$notChars = qr[^abc]/;
($_) = "abcdef" =~
/
  ((?&BB).*)
| (?!)
  (?<BB>
      (?<=$chars)(?=$notChars)
    | (?<=$notChars)(?=$chars)
  )
/x;
print;
+4
source share
4 answers

Lookbehind node , , , , . subrule, , , , . , lookbehind.

, Can't determine the length of '(?&W)' for use in lookbehind Variable length lookbehind not implemented.

+7

:

(?<=(?&W))(?=(?&NW))
    |(?<=(?&NW))(?=(?&W))

Perl 5 ( ()).

. <= , (), - lookbehind.

: .

, , , , [^ abc], , . , ! Abc.

Perl 6, , .

. RFC Perl 6 http://perl6.org/archive/rfc/72.html

+1

, , lookbehind. capture:

/(?|a(?<toto>ef)|b(?<toto>ghi))/
+1

Looks like an error for me, but resolving the error can only consist in having a separate error message "Recursive search capture group not implemented" :)

+1
source

All Articles