Skip to content

clarification on whether lookahead inside lookbehind can see beyond the lookbehind #5608

Closed

Description

@robertmorelli

What input is a lookahead inside a lookbehind allowed to inspect? On "ba", Racket returns #f when (?=a) is inside the lookbehind, but #t when the same lookahead is immediately outside it.

This seems consistent with limiting the nested lookahead to the portion of input examined by the lookbehind. ECMAScript, Perl, and PCRE2 instead let it see the a in the original input. Is Racket's boundary intentional? To be honest, I feel like the racket semantics make more sense but if the goal is to match other engines this might be a bug.

example:

(regexp-match? #px"^b(?<=b(?=a))a$" "ba") ; #f
(regexp-match? #px"^b(?<=b)(?=a)a$" "ba") ; #t

For comparison, JS returns true for both:

/^b(?<=b(?=a))a$/.test("ba") // true
/^b(?<=b)(?=a)a$/.test("ba") // true

system:
Racket v9.3 [cs]
macOS 27.0 (build 26A428), arm64

Activity

  1. added a commit that references this issue on Oct 14, 2026
    1a643af
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions