Socket
Socket
Sign inDemoInstall

regexp-to-ast

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regexp-to-ast

Parses a Regular Expression and outputs an AST


Version published
Weekly downloads
867K
decreased by-1.44%
Maintainers
1
Weekly downloads
 
Created

What is regexp-to-ast?

The `regexp-to-ast` npm package is a utility that converts regular expressions into Abstract Syntax Trees (ASTs). This can be useful for analyzing, transforming, or generating regular expressions programmatically.

What are regexp-to-ast's main functionalities?

Convert RegExp to AST

This feature allows you to convert a regular expression into its corresponding Abstract Syntax Tree (AST). The AST can then be used for further analysis or transformation.

const { regExpParser } = require('regexp-to-ast');
const ast = regExpParser.pattern('/a*b+/');
console.log(JSON.stringify(ast, null, 2));

Analyze AST

This feature demonstrates how to traverse and analyze the AST generated from a regular expression. You can inspect different nodes and their properties.

const { regExpParser } = require('regexp-to-ast');
const ast = regExpParser.pattern('/a*b+/');
function analyzeAST(node) {
  if (node.type === 'Character') {
    console.log(`Character: ${node.value}`);
  }
  if (node.children) {
    node.children.forEach(analyzeAST);
  }
}
analyzeAST(ast);

Other packages similar to regexp-to-ast

Keywords

FAQs

Package last updated on 15 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc