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.
This example demonstrates the problem:
When it is executed in console using
qjs.exe test.js, it givesSyntaxError: invalid character in class in regular expressionat the definition ofre.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.