Skip to main content

Regex Parser

@r101/parser is the parser that powers regex101. The commercial package provides the same pattern and substitution parsers for browser and Node.js applications.

The package supports ten regex flavors. Each parse returns typed tokens, parser state, source positions, and flavor-specific errors.

What you get

  • Ten regex flavors: PCRE, PCRE2, JavaScript, Python, Go, Java, .NET, Rust, POSIX ERE, and POSIX BRE.
  • Pattern and substitution parsing: use one package for both editor inputs.
  • Flavor-specific validation: each flavor has its own syntax, flags, Unicode rules, and error checks.
  • Error recovery: invalid input still produces tokens for editor highlighting and diagnostics.
  • Typed integration: the package includes TypeScript types and ESM and CommonJS builds.

Proven in production

  • regex101 uses the parser for live editing and explanations.
  • Nearly 4,000 automated tests cover valid and invalid syntax.
  • Statement and line coverage exceed 95%.
  • The parser processes input in linear time.

What makes it different

The parser models syntax as a typed token tree. Tokens include parent relationships, referenced groups, match-width metadata, and exact source positions.

Validation follows the rules of the selected flavor. This includes Unicode modes, replacement syntax, character-class operations, and lookbehind width rules.

A good fit for

  • IDE and editor tooling
  • SaaS products with regex features
  • Security and analysis platforms
  • Internal developer tools
  • Open source maintainers who want commercial-grade reliability

Start here

For licensing and package access, contact contact@regex101.com.