JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1363789
  • Score
    100M100P100Q200651F
  • License MIT

Parses a Regular Expression and outputs an AST

Package Exports

  • regexp-to-ast

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (regexp-to-ast) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm version CircleCI Coverage Status

regexp-to-ast

Reads a JavaScript Regular Expression literal(text) and outputs an Abstract Syntax Tree.

Installation

  • npm
      npm install regexp-to-ast
  • Browser
      <script src="https://unpkg.com/regexp-to-ast/lib/parser.js"></script>

API

The API is defined as a TypeScript definition file.

Usage

const RegExpParser = require("regexp-to-ast").RegExpParser
const regexpParser = new RegExpParser.parser()

// from a regexp text
const output = regexpParser.pattern("/a|b|c/g")

// text from regexp instance.
const input2 = /a|b/.toString()
// The same parser instance can be reused
const anotherOutput = regexpParser.pattern(input2)

Compatibility

This library is written in ES5 style and is compatiable with all major browsers and modern node.js versions.

TODO / Limitations