MCPcopy Create free account
hub / github.com/CJex/regulex

github.com/CJex/regulex @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
508 symbols 967 edges 28 files 17 documented · 3% 14 cross-repo links updated 4y ago★ 5,82821 open issues

Browse by type

Functions 404 Types & classes 104
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Regulex

Regulex is a JavaScript Regular Expression Parser & Visualizer.

Try it now: https://jex.im/regulex/

This project is under reconstruction!

Features

  • Written in pure JavaScript. No backend required.
  • You can embed the graph on you own site through HTML iframe element.
  • Detailed error message. In most cases it can point out the precise syntax error position.
  • No support for octal escape. Yes it is a feature! ECMAScript strict mode doesn't allow octal escape in string, but many browsers still allow octal escape in regex. In regulex, DecimalEscape will always be treated as back reference. If the back reference is invalid, e.g. /\1/, /(\1)/, /(a)\2/, or DecimalEscape appears in charset(because in this case it can't be explained as back reference, e.g. /(ab)[\1]/, Regulex will always throw an error.

Install for Node.js

npm install regulex

Local Build for Browser

This command will generate bundle dist/regulex.js for browser side:

git checkout legacy
npm install -g requirejs
r.js -o build-config.js

API

Parse to AST

var parse = require("regulex").parse;
var re = /var\s+([a-zA-Z_]\w*);/ ;
console.log(parse(re.source));

Visualize

var parse = require("regulex").parse;
var visualize = require("regulex").visualize;
var Raphael = require('regulex').Raphael;
var re = /var\s+([a-zA-Z_]\w*);/;
var paper = Raphael("yourSvgContainerId", 0, 0);
try {
  visualize(parse(re.source), getRegexFlags(re), paper);
} catch(e) {
  if (e instanceof parse.RegexSyntaxError) {
    logError(re, e);
  } else {
    throw e;
  }
}

function logError(re, err) {
  var msg = ["Error:" + err.message, ""];
  if (typeof err.lastIndex === "number") {
    msg.push(re);
    msg.push(new Array(err.lastIndex).join("-") + "^");
  }
  console.log(msg.join("\n"));
}


function getRegexFlags(re) {
  var flags = "";
  flags += re.ignoreCase ? "i" : "";
  flags += re.global ? "g" : "";
  flags += re.multiline ? "m" : "";
  return flags;
}

Extension points exported contracts — how you extend this code

browse all types & interfaces →

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 238
Method 166
Class 70
Interface 33
Enum 1

Languages

TypeScript100%

Modules by API surface

src/Parsec.ts197 symbols
src/Kit.ts87 symbols
src/AST.ts38 symbols
test/ParsecSpec.ts33 symbols
src/grammar/Base.ts29 symbols
test/grammar/BaseGen.ts26 symbols
src/grammar/JSRE.ts14 symbols
test/utils.ts12 symbols
src/web/EventEmitter.ts12 symbols
src/web/TextEditor.ts11 symbols
src/web/RegexEditor.ts11 symbols
test/benchmark/Parsec.ts10 symbols

Dependencies from manifests, versioned

@types/benchmark1.0.31 · 1×
@types/chai4.1.7 · 1×
@types/lodash4.14.0 · 1×
@types/mocha5.2.7 · 1×
@types/node12.6.9 · 1×
@types/optimize-css-assets-webpack-plugin1.3.4 · 1×
@types/webpack4.4.32 · 1×
@webpack-cli/serve0.1.8 · 1×
acorn6.1.0 · 1×

For agents

$ claude mcp add regulex \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page