Registry / serialization / regexp-tree-cli

regexp-tree-cli

JSON →
library0.0.21jsnpmunverified

Command-line interface for the regexp-tree library (v0.0.21). Parses, optimizes, and transpiles JavaScript/ECMAScript regular expressions, producing ASTs with loc support, NFA/DFA transition tables, and compatibility transpilation. Unlike regex libraries that only match or replace, regexp-tree-cli operates at the AST level for transformations and analysis. Primarily a CLI tool, but can be used programmatically via the regexp-tree package. Last stable release is v0.0.21; development is infrequent but the underlying regexp-tree library is more actively maintained.

npm install regexp-tree-cli
INSTALL
IMPORT
SIG · REGEXP-TREE-CLI
R
regexp-tree-cli
serializationjavascriptv0.0.21
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
import { parse } from 'regexp-tree'
const parse = require('regexp-tree').parse
regexp-tree is the programmatic backend; this CLI is a thin wrapper. ESM import is standard.
generate
import { generate } from 'regexp-tree'
import { generate } from 'regexp-tree-cli'
generate converts AST back to regex string; available only from regexp-tree
optimize
import { optimize } from 'regexp-tree'
import optimize from 'regexp-tree'
optimize is a named export, not default

Install CLI globally, parse a regex with location and optimizer output.

npm install -g regexp-tree-cli regexp-tree-cli -e '/a|b/i' -o -l
regexp-tree-cli --version
Debug
Known issues
gotchaThe expression must be wrapped in slashes and quotes, e.g., -e '/[a-z]/i'. Omitting slashes will cause parse failure.
fix
Always include slashes: regexp-tree-cli -e '/pattern/flags'
affects: >=0.0.1
deprecatedThe --compat option for compat-transpiler may not cover all modern regex features (e.g., lookbehind).
fix
Use regexp-tree's compat-transpiler directly for full support.
affects: <=0.0.21
gotchaCLI output is JSON, but with no newline at end; piping may break scripts expecting trailing newline.
fix
Use `--table` output to get formatted tables for NFA/DFA.
affects: <=0.0.21
Errors
Common errors & fixes
ReferenceError: regexp-tree-cli is not defined
Trying to import the CLI package directly in Node.js code instead of using the command line.
fix
Use the CLI from the terminal, or import 'regexp-tree' for programmatic use.
Error: Invalid regular expression: / /: Nothing to repeat
Passing an expression without slashes or with an empty regex.
fix
Wrap in slashes: -e '/ /' or provide a valid pattern.
SyntaxError: Unexpected token 'u' in JSON at position 0
Using --compat or --optimize on an unsupported regex, producing non-JSON output.
fix
Ensure the regex is valid and pattern is enclosed in slashes.
Upgrade
Version history
0.0.21latest on npm
Audit
Dependencies
regexp-treerequiredCore regex parsing and transformation engine
Agent activity
4 hits · last 30 days
node
4
Resources
regexp-tree-cli — npm install regexp-tree-cli · libregistry