Regulex is a JavaScript Regular Expression Parser & Visualizer.
Try it now: https://jex.im/regulex/
This project is under reconstruction!
/\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.npm install regulex
This command will generate bundle dist/regulex.js
for browser side:
git checkout legacy
npm install -g requirejs
r.js -o build-config.js
var parse = require("regulex").parse;
var re = /var\s+([a-zA-Z_]\w*);/ ;
console.log(parse(re.source));
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;
}