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.
- CLI
- JavaScript
- Scala
$ recheck --dialect=javascript '/^(a|a)*$/'
import { check } from "recheck";
await check("^(a|a)*$", "", { dialect: "javascript" });
import codes.quine.labs.recheck.ReDoS
import codes.quine.labs.recheck.common.Parameters
import codes.quine.labs.resyntax.dialect.Dialect
ReDoS.check("^(a|a)*$", "", Parameters(dialect = Dialect.JavaScript))
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.
| Flag | RegExp property | Inline | Notes |
|---|---|---|---|
d | hasIndices | No effect on matching. | |
g | global | No effect on matching, since recheck models a search from the start. | |
i | ignoreCase | (?i:...) | |
m | multiline | (?m:...) | |
s | dotAll | (?s:...) | |
u | unicode | An error with v. | |
v | unicodeSets | An error with u. | |
y | sticky | The match starts at the start of the input (lastIndex is 0). |
Approximations
- With the
yflag, the match starts only at the start of the input, as withlastIndexof0. A match from a laterlastIndexis not modeled, sorecheckmisses a pattern that is slow only there, where a look-behind,\b,\Bor a multiline^sees the text before the starting position (e.g./(?<=a)(?:b|b)*$/ywithlastIndexof1on'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.