Skip to content

regex loses a capture from the last successful repetition #1759

Closed

Description

@robertmorelli

Build environment: macOS 27.0 (build 26A428), arm64
Moddable SDK version: 10.0.0 (commit 5f215f7)
Target device: macOS desktop XS test shell (xst)

Description
The repeated group matches a, but its capture is missing from the final match result.

Steps to Reproduce
repro.js:

print(String(/(a|)*c/.exec("ac")[1])); // prints undefined

run xst -s repro.js

Expected behavior
prints a

Activity

  1. added
    conformance
    on Oct 11, 2026
  2. phoddie commented on Oct 13, 2026

    @phoddie
    Collaborator

    Thank you for this report, and the many others! We intend to work through the issues in the coming days and weeks.

    In-depth testing of RegExp is very welcome. XS uses its own RegExp engine, optimized for small devices. This engine has allowed us to support the many enhancements made to JavaScript regular expressions over the years. But that also means that it is not entirely surprising that you've found some divergences from the standard. You can learn a bit more about the approach on our blog post, A smaller, more compatible regular expression engine for XS.

    Because most of your test cases are small, it can be more convenient just to pass them as strings to execute on the command line rather than a separate file. (No need to update your reports. This is just FYI.)

    xst -e 'print(String(/(a|)*c/.exec("ac")[1]));'
    

    You can also pass multiple strings:

    xst -e 'print(1);' 'print(2);' 'print(3);'
    

    XS generally maintains excellent compatibility with test262. From our first look, it appears none of the RegExp issues you've reported to this repository are covered by test262. It would be great to have cases for them added to test262 to contribute to TC39's goal of ensuring consistency across engines.

  3. added
    confirmed
    on Oct 29, 2026
  4. phoddie commented on Oct 29, 2026

    @phoddie
    Collaborator

    The fix for this issue will be included in Moddable SDK 10.1.0.

  5. added
    fixed - please verify
    on Nov 8, 2026
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

    confirmedconformancefixed - please verify

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions