Skip to main content

Regex Parser

Use @r101/parser when your application needs to understand regex syntax without executing a match. It parses patterns and substitution strings into typed tokens.

Request parser access and pricing.

The parser is a separate commercial package.

Features​

  • Ten syntax flavors: PCRE, PCRE2, JavaScript, Python, Go, Java, .NET, Rust, POSIX ERE, and POSIX BRE.
  • Separate functions for pattern and substitution parsing.
  • Flavor-specific syntax validation and errors.
  • Source positions and token relationships for editor highlighting.
  • TypeScript types for tokens, parser options, and results.

See Capabilities for the supported syntax and public helpers.

Use in regex101​

regex101 uses this parser for syntax highlighting, syntax errors, and explanations during live editing.

See Performance and reliability to measure parsing in your application.

Token data​

Each result contains the source text, tokens, parser state, and a patternError status. Tokens contain facts specific to their syntax.

For example, a group can contain child tokens and capture information. A quantifier can contain repetition bounds.

The parser does not return matched text. Use a regex engine to execute patterns or apply substitutions.

Integration uses​

Your taskParser role
Build a pattern editorIdentify syntax and highlight errors.
Build a substitution editorParse insertions and flavor-specific replacement syntax.
Inspect patternsTraverse typed tokens and their source positions.
Execute a searchPair the parser with a regex engine; matching is outside this package.

Package access and setup​

  1. Request package access.
  2. Parse your first pattern.
  3. Evaluate compatibility and performance.