v160 · javascript · regexp
Annex B literal trap
The grammar adds \A, \z and \Z only under [+UnicodeMode]. Outside u/v, web-compat Annex B keeps treating them as identity escapes — the plain letters A, z, Z — so a pattern copied from Perl or PCRE without the flag compiles happily and silently means something else. Even the explainer’s own /end\Z/ example has no u. This page runs every edge case live.
Edge-case battery
Expected values are what the spec text says. Rows marked needs feature throw SyntaxError: Invalid escape on engines without buffer boundaries; that is reported as unsupported, not as a spec failure.
| Regex | Input | Spec says | Observed | Verdict | Why |
|---|---|---|---|---|---|
| Not run yet. | |||||
Compare with and without Unicode mode
migration checklist
- Porting a pattern that uses
\A/\z/\Z? Adduorv. A linter can flag\A,\z,\Zin non-Unicode patterns, since they are almost never meant literally. - Don’t quantify them (
\A*) and don’t put them in a class ([\A]): both are early SyntaxErrors in Unicode mode. \Zabsorbs exactly one terminator, and\r\ncounts as one. Use\zwhen trailing newlines must be rejected.- Lower-case
\aand upper-case\Zare not related:\astays an invalid escape in Unicode mode.