@eslint-community/regexpp
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The @eslint-community/regexpp
is a highly efficient tool designed for parsing regular expressions in ECMAScript. This module enables developers to carry out tasks like parsing, validating, and visiting each node of a regular expression's Abstract Syntax Tree (AST).
The usage of @eslint-community/regexpp
involves a series of straightforward steps. First and foremost, you need to install the npm package using the command:
$ npm install @eslint-community/regexpp
Afterwards, import the necessary components such as AST
, RegExpParser
, RegExpValidator
, RegExpVisitor
, parseRegExpLiteral
, validateRegExpLiteral
, and visitRegExpAST
.
import {
AST,
RegExpParser,
RegExpValidator,
RegExpVisitor,
parseRegExpLiteral,
validateRegExpLiteral,
visitRegExpAST
} from "@eslint-community/regexpp";
Now you can use these components to parse, validate and visit regex nodes. Here's how you would parse a literal:
const literal = "/abc/g";
const parsedLiteral = parseRegExpLiteral(literal);
To validate a literal, you'd do something like this:
const isValid = validateRegExpLiteral(literal);
And to visit each node in a regex's AST, you'd do:
visitRegExpAST(parsedLiteral, {
onQuantifierEnter(node) {
console.log(`Visiting a quantifier: ${node.raw}`);
}
});
For thorough understanding and better utilization of this package's capabilities, it is recommended that you refer to detailed documentation. Detailed documentation about @eslint-community/regexpp
can be found directly on the official repository at https://github.com/eslint-community/regexpp
. Instructions for installation, usage, and comprehensive API references are all provided in the repository's README file.