Regulex
Regulex is a JavaScript Regular Expression Parser & Visualizer.
Try it now: https://jex.im/regulex/
This is the legacy version!
Switch export method to commonjs.
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-cjs
Using
const regulex = ;// or import * as regulex from 'regulex-cjs'
API
Parse to AST
var parse = parse;var re = /var\s+;/ ;console;
Visualize
var parse = parse;var visualize = visualize;var Raphael = Raphael;var re = /var\s+;/;var paper = ;try ; catche if e instanceof parseRegexSyntaxError ; else throw e; { var msg = "Error:" + errmessage ""; if typeof errlastIndex === "number" msg; msg; console;} { var flags = ""; flags += reignoreCase ? "i" : ""; flags += reglobal ? "g" : ""; flags += remultiline ? "m" : ""; return flags;}