Skip to content

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

Closed

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.

Activity

  1. bellard commented on Sep 26, 2026

    @bellard
    Owner

    Fixed

  2. added 2 commits that reference this issue on Oct 10, 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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions