Skip to content

RegexLimits

RegexLimits = object

Defined in: packages/format-regex/src/limits.ts:10

Bounds on what a pattern may cost to compile and to run.

The Pike VM gives an unconditional linear time guarantee, but linear in a program the pattern itself sizes: a{1,200000} expands to one instruction per repetition before a single character is read. These bounds are the matching space guarantee, and they are what makes it safe to compile a pattern that arrived from outside the program.

readonly optional maxProgramSize?: number

Defined in: packages/format-regex/src/limits.ts:17

Most instructions a compiled program may hold.

Bounds compile-time memory. Counted bounded quantifiers ({m,n}) are the construct that reaches it, since each repetition emits its own copy.


readonly optional maxSteps?: number

Defined in: packages/format-regex/src/limits.ts:25

Most thread activations one execProgram call may perform.

Bounds run-time work, which grows as program size × input length even though neither factor alone is unbounded.