Skip to content

compileRegex

compileRegex(source, limits?): CompiledRegex

Defined in: packages/format-regex/src/regex.ts:27

Parses and compiles source — the Lexer → AST → Codec pipeline end to end.

string

RegexLimits

CompiledRegex

const re = compileRegex("(\\d+)-(\\d+)");
re.exec("pages 10-20"); // { index: 6, length: 5, text: "10-20", groups: [...] }
```;
## Throws
If the compiled program outgrows
[RegexLimits.maxProgramSize](../type-aliases/RegexLimits.md#maxprogramsize). The returned matcher throws the same
error if a run outgrows [RegexLimits.maxSteps](../type-aliases/RegexLimits.md#maxsteps).