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:
($_) = "abcdef" =~
/
((?&BB).*)
|
(?!)
(?<W>[abc])
(?<NW>[^abc])
(?<BB>
(?<=(?&W))(?=(?&NW))
|(?<=(?&NW))(?=(?&W))
)
/x;
print;
What does not work. However, if I do this:
($_) = "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.
$chars = qr/[abc]/;
$notChars = qr[^abc]/;
($_) = "abcdef" =~
/
((?&BB).*)
| (?!)
(?<BB>
(?<=$chars)(?=$notChars)
| (?<=$notChars)(?=$chars)
)
/x;
print;
source
share