Home

Awesome

@eslint-community/regexpp

npm version Downloads/month Build Status codecov

A regular expression parser for ECMAScript.

💿 Installation

$ npm install @eslint-community/regexpp

📖 Usage

import {
    AST,
    RegExpParser,
    RegExpValidator,
    RegExpVisitor,
    parseRegExpLiteral,
    validateRegExpLiteral,
    visitRegExpAST
} from "@eslint-community/regexpp"

parseRegExpLiteral(source, options?)

Parse a given regular expression literal then make AST object.

This is equivalent to new RegExpParser(options).parseLiteral(source).

validateRegExpLiteral(source, options?)

Validate a given regular expression literal.

This is equivalent to new RegExpValidator(options).validateLiteral(source).

visitRegExpAST(ast, handlers)

Visit each node of a given AST.

This is equivalent to new RegExpVisitor(handlers).visit(ast).

RegExpParser

new RegExpParser(options?)

parser.parseLiteral(source, start?, end?)

Parse a regular expression literal.

parser.parsePattern(source, start?, end?, flags?)

Parse a regular expression pattern.

parser.parseFlags(source, start?, end?)

Parse a regular expression flags.

RegExpValidator

new RegExpValidator(options)

validator.validateLiteral(source, start, end)

Validate a regular expression literal.

validator.validatePattern(source, start, end, flags)

Validate a regular expression pattern.

validator.validateFlags(source, start, end)

Validate a regular expression flags.

RegExpVisitor

new RegExpVisitor(handlers)

visitor.visit(ast)

Validate a regular expression literal.

📰 Changelog

🍻 Contributing

Welcome contributing!

Please use GitHub's Issues/PRs.

Development Tools