Files
scriptc/tests/diagnostics/regex.ts
T
Chris Tate 84916f25e4 Support the regex v flag
Regex literals and new RegExp calls accept the v (unicode sets) flag, which
the vendored engine implements: class subtraction and intersection, nested
classes, \q{...} string literals and properties of strings. The flag uses
unicode mode for pattern decoding and string iteration, and flags read in
getter order (dgimsuvy). Regex literals now also report their flags in
getter order, as Node does for /x/yg, and the flag getters (global,
unicodeSets and the rest) compile on statically typed regexes.

In v mode the engine rejected `-` and doubled punctuation outside a
character class, and the `\-` escape inside \q{...}. It now applies the
class-only checks inside classes and \q{...} only, and parses \q{...}
contents with the class escapes, matching Node. The d flag is still
refused.
2026-10-18 03:37:40 -05:00

12 lines
429 B
TypeScript

// The d flag is outside the native slice; .groups needs a
// statically-known regex. Named capture groups compile (corpus 2604).
// Method values and regex union arms remain unsupported; arrays compile.
const indices = /cat/d;
const asValue = /x/.test;
const maybe: RegExp | undefined = /a/;
function readGroups(re: RegExp): void {
const m = re.exec("2024-07");
if (m) console.log(m.groups);
}
readGroups(/(?<year>\d{4})/);