v160 · javascript · regexp
Assertion position map
An inspection tool for zero-width anchors. For the text below, each row runs one assertion as a global Unicode-mode regex with matchAll and lists every index where it succeeded. Toggle m and watch ^/$ multiply while \A, \z and \Z stay put. The right-hand columns re-run the proposal’s desugared RegExp-modifier forms and check they agree.
Map the positions
Use the presets to insert \r\n, lone \r or U+2028, which are hard to type. (A textarea turns typed or pasted \r into \n, so preset text is kept exactly until you edit it; the summary shows the exact string.)
| Assertion | Indices | Desugared form | Desugared indices | Agree? |
|---|---|---|---|---|
| Not run yet. | ||||
Positions drawn on the text
reading the map
- Index n means “the gap before character n”; index = length is the gap after the last character.
\Zon"end\n\n"only matches at 4 and 5: it lets one terminator sit between it and the end, never two.- On
"a\r\nb\r\n",\Zmatches at 4, 5 and 6: before the final\r\npair, between\rand\n(the lone-\nalternative is followed by the end), and at the end itself. A global replace with\Zcan therefore split a CRLF pair — worth knowing before using it inreplaceAll. - The desugared forms use RegExp modifiers
(?-m:…)(Chrome 125+). They work even where the new escapes do not, which is what makes a transpiling fallback possible.
see also
- Regular Expression Buffer Boundaries — feature index
- Buffer anchor tester
- Portable pattern import — uses these desugarings as a fallback
- ChromeStatus entry
- Spec text (CompileAssertion)