[Note: parts of this message were removed to make it a legal post.]
Docs say that the regexp cannot be unlimited. But it is by far not
only a fixed length literal. "|" is certainly meta in an assertion -
the second line would not match if the lookbehind assertion was a
literal.
Yes, please excuse the terseness of my last response. I wrote it as I was
rushing out the door.
What I meant, but did not properly clarify, is; the contents of assertions
are not *full* expressions. They can not contain quantifiers, they can not
contain captures, and they can not include backreferences or anything that
can complicate determining the length of the contents. Obviously alternation
is allowed, since that's what we were discussing. However, only as long as
the alternatives abide by the limitations.
Ruby's regular expression engine is quite flexible in this regard, as it
allows the alternatives to be of different lengths, unlike some other
engines that require them to be of the same length.
----8<----
The root issue still exists
irb(main):014:0> "a ac".scan /(?<!a a|b)c/i
=> []
irb(main):015:0> "A Ac".scan /(?<!a a|b)c/i
=> ["c"]
irb(main):016:0> "ac".scan /(?<!a|b)c/i
=> []
irb(main):017:0> "Ac".scan /(?<!a|b)c/i
=> []
----8<----
IMHO this is a bug.
OK, now that we've eliminated the syntax and the double-negative confusion,
I see the issue clearly. Thank you for your patience
It might be a bug, but since the contents of assertions do not go through
the full eval/exec cycle of "regular" regular expressions, this could be
just another limitation of assertions. It might be difficult to figure out
the last options in effect because they can be inserted multiple times in an
expression, on their own (from here on) and they can be nested. Which of
these would be used? Maybe just use the top level options? That can
potentially introduce more confusion.
Anyway, it's definitely worth reporting. Worst case, we'll find out it's a
limitation, and best case, it will end being a feature request, if not a
bug.
Is the OP able/willing to report this?
http://redmine.ruby-lang.org/
Regards,
Ammar