in reply to Re: The "anchor" misnomer in regexes
in thread The "anchor" misnomer in regexes

Hmm, well, the engine is required to switch directionality to check lookbehind assertions, and given that, the optimizer would be silly not to turn /\s+$/ into /$<?after \s+>/. (With allowances for differing capture semantics, of course.)

Replies are listed 'Best First'.
Re^3: The "anchor" misnomer in regexes
by tilly (Archbishop) on Dec 17, 2005 at 01:55 UTC
    AFAIK, the current engine has no such requirement. Instead the restriction is placed that says that only fixed-length lookbehind expressions will work. That way the engine can get to the assertion, backs up, tries to match, then proceed based on that answer. No need to match backwards.

    By contrast Java can match backwards, and the capacity shows in its ability to do variable width lookbehind assertions.

Re^3: The "anchor" misnomer in regexes
by duff (Parson) on Dec 17, 2005 at 03:15 UTC

    Well, I guess it was my lack of imagination then :-) But does that mean that right-to-left directionality changes will all be encapsulated in lookbehinds?