{"library":"regjsparser","title":"Regular Expression Parser for JavaScript","description":"RegJSParser is a JavaScript library designed for parsing JavaScript regular expressions into an abstract syntax tree (AST). It provides a programmatic way to analyze and manipulate regular expression patterns, enabling tools that need to understand the structure of regular expressions. The current stable version is 0.13.1, with recent releases indicating an active maintenance schedule, primarily focused on dependency updates, performance improvements, bug fixes, and keeping up with the latest Unicode specifications (e.g., Unicode 17.0.0 in v0.13.0). Key differentiators include its ability to parse various modern RegExp features, such as Unicode property escapes, named capture groups, and lookbehind assertions, which are often toggled via an options object during parsing. It ships with TypeScript types, facilitating its integration into modern TypeScript projects.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install regjsparser"],"cli":null},"imports":["import { parse } from 'regjsparser';","import type { AST } from 'regjsparser';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { parse } from 'regjsparser';\n\n// Basic parsing of a regular expression\nconst simplePattern = '^hello(world)?$';\nconst simpleAst = parse(simplePattern);\nconsole.log('Simple AST:', JSON.stringify(simpleAst, null, 2));\n\n// Parsing with advanced features enabled via options\n// Note: These features are typically opt-in to maintain compatibility\nconst advancedPattern = '(?<greeting>hi)\\p{Script=Latin}(?<name>.*)(?<!bye)';\nconst advancedAst = parse(advancedPattern, '', {\n  unicodePropertyEscape: true, // Enables \\p{...} and \\P{...}\n  namedGroups: true,           // Enables (?<name>...)\n  lookbehind: true             // Enables (?<=...) and (?<!...)\n});\nconsole.log('\\nAdvanced AST:', JSON.stringify(advancedAst, null, 2));\n\n// Example of parsing a regex with flags\nconst flaggedPattern = '/test/gi';\nconst flaggedAst = parse(flaggedPattern, 'gi');\nconsole.log('\\nFlagged AST:', JSON.stringify(flaggedAst, null, 2));","lang":"typescript","description":"Demonstrates basic and advanced parsing of regular expressions, including enabling opt-in features like Unicode property escapes, named groups, and lookbehind assertions, and parsing with flags.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}