Skip to main content

JavaScript

Describes how recheck checks a regular expression of the javascript dialect, which is the default.

Engine​

recheck follows the syntax and the semantics of ECMAScript 2026 RegExp, as V8 implements it.

Settings​

The javascript dialect has no settings.

$ recheck --dialect=javascript '/^(a|a)*$/'

Flags and Units​

The matching unit is utf16, or utf16-code-point with the u or v flag (see Matching Units).

recheck supports the following flags of RegExp.

FlagRegExp propertyInlineNotes
dhasIndicesNo effect on matching.
gglobalNo effect on matching, since recheck models a search from the start.
iignoreCase(?i:...)
mmultiline(?m:...)
sdotAll(?s:...)
uunicodeAn error with v.
vunicodeSetsAn error with u.
ystickyThe match starts at the start of the input (lastIndex is 0).

Approximations​

  • With the y flag, the match starts only at the start of the input, as with lastIndex of 0. A match from a later lastIndex is not modeled, so recheck misses a pattern that is slow only there, where a look-behind, \b, \B or a multiline ^ sees the text before the starting position (e.g. /(?<=a)(?:b|b)*$/y with lastIndex of 1 on 'a' + 'b'.repeat(n) + '!').

Runtime-Attack Verification​

  • Command: node -.
  • Matching: RegExp.prototype.exec.
  • Engine limits: none.
  • Engine errors: RangeError (e.g. V8 raises it for /^(?:a|b)*$/ on 10,000,000 characters).
  • Environment variable: RECHECK_NODE.