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 task | Parser role |
|---|---|
| Build a pattern editor | Identify syntax and highlight errors. |
| Build a substitution editor | Parse insertions and flavor-specific replacement syntax. |
| Inspect patterns | Traverse typed tokens and their source positions. |
| Execute a search | Pair the parser with a regex engine; matching is outside this package. |