v160 · javascript · regexp

Portable pattern import

The proposal’s portability argument, end to end. Editor grammars, linters and form schemas ship regexes as JSON strings written for PCRE or Oniguruma, where \A/\z/\Z are everyday syntax. This page imports such a config, compiles it with u, feature-detects, and — only where the engine refuses — transpiles the escapes to their RegExp-modifier desugarings as a labelled fallback. It then scans a document and wires the config’s field pattern into a real <input pattern>.

Probing this browser…

1. Import the config

Import strategy
Every pattern compiled with new RegExp(source, flags) and run with matchAll
RuleCompiled asEffective regexMatches (line:col text)
Not imported yet.
 

2. Use the config’s field pattern in a form

HTML compiles pattern as ^(?:pattern)$ with the v flag. If that fails to compile the attribute is ignored and every value is valid — so on an engine without buffer boundaries, a pattern using \A silently stops validating.

 

the transpiler

It walks the source once, skipping escaped characters and tracking (nested v-mode) character classes, and replaces only top-level \A, \z, \Z with the explainer’s desugarings: (?-m:^), (?-m:$), (?=(?:\r\n|\n|\r|
|
)?(?-m:$)). It needs RegExp modifiers (Chrome 125+). It is a migration aid, not the feature — rows that used it are labelled fallback.

see also