Skip to content

Some regular expressions, which contain “-”, fail in “v” mode #520

@Viorel

Description

@Viorel

This example demonstrates the problem:

// File: test.js
// Using QuickJS 2026-06-04.

const re = /-/v;

console.log( re.test( "3-4" ));

When it is executed in console using qjs.exe test.js, it gives SyntaxError: invalid character in class in regular expression at the definition of re.

If the “v” flag is removed, then it works.

The definition const re = RegExp( "-", "v") fails too.

Even if this example does not require the “v” flag, it should not fail. The problem can be reproduced with other examples, where “v” is required and which also contain “-”. (For example, this fails: const re = /-[[a-z]--[c]]/v; this works: const re = /[[a-z]--[c]]/v).

The issue is not observed in other engines that supports “v” mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions