Skip to content

Wront behavior when replacing with unknown named groups #17174

@nicolo-ribaudo

Description

@nicolo-ribaudo

💻

  • Would you like to work on a fix?

How are you using Babel?

Other (Next.js, Gatsby, vue-cli, ...)

Input code

"abcd".replace(/(?<foo>b)/, "[$<bar>]") 

Configuration file name

No response

Configuration

Using @babel/plugin-transform-named-capturing-groups-regex

Current and expected behavior

When running the input code, it produces "a[]cd". When transpiling it with Babel, it produces "a[$undefined]cd".

Environment

v7.26

Possible solution

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions