Skip to content

regex Modifier syntax not working as expected #60030

@hugo9655

Description

@hugo9655

Version

v24.9.0

Platform

Windows 10 LTSC

Subsystem

No response

What steps will reproduce the bug?

  1. Open node in a CLI.
  2. Paste the following example regex:
    var e = "-SAd";
    e.match(/[\[-](?-i:\b(test|SAD|Hello)\b)/i);
  3. Notice how it finds a match when it shouldnt have.
    Image

How often does it reproduce? Is there a required condition?

Can be replicated almost all of the time, though sometimes its inconsistent in whether it works or not.

What is the expected behavior? Why is that the expected behavior?

In the example above it should only find a match if the case-sensitive modifier capture group finds -SAD, no other variations.

What do you see instead?

It matches -SAd.

Additional information

This issue is not exclusive to node.js, the same behaviour can be found in common browsers. But im hoping it can be fixed in node.js at least.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions