regexp-tree-cli

raw JSON →
0.0.21 verified Fri May 01 auth: no javascript

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.

error ReferenceError: regexp-tree-cli is not defined
cause 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 Error: Invalid regular expression: / /: Nothing to repeat
cause Passing an expression without slashes or with an empty regex.
fix
Wrap in slashes: -e '/ /' or provide a valid pattern.
error SyntaxError: Unexpected token 'u' in JSON at position 0
cause Using --compat or --optimize on an unsupported regex, producing non-JSON output.
fix
Ensure the regex is valid and pattern is enclosed in slashes.
gotcha The 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'
deprecated The --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.
gotcha CLI 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.
npm install regexp-tree-cli
yarn add regexp-tree-cli
pnpm add regexp-tree-cli

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