rexact-regex
v0.2.0
Published
Prove regex equivalence, find ReDoS, compare dialects (WebAssembly build of Rexact)
Maintainers
Readme
rexact-regex
WebAssembly build of Rexact: decide whether two regular expressions are equivalent (with a checkable certificate or a shortest counterexample), find catastrophic-backtracking patterns, and compare dialects. No dependencies, no network access.
const rexact = require('rexact-regex');
rexact.equiv('(a|b)*', '(a*b*)*').result; // 'EQUIVALENT'
rexact.equiv('(ab|a)(c|bc)', 'a(bc|c)'); // NOT_EQUIVALENT, counterexample "abbc"
rexact.redos('(a+)+$').result; // 'EXPONENTIAL'
rexact.compare('^[a-z]+$', '^[a-zA-Z]+$'); // A_SUBSET_OF_B with a witness
rexact.dialects('\\d+'); // how each dialect reads the text
rexact.equiv('[', 'a'); // throws { code: 'RX-P007', ... }Functions: equiv, compare, redos, lint, and through callRaw also dialects, explain,
trace, automaton. Options (second or third argument): { dialect, flags, mode }.
The results are byte-identical to the native command-line program's JSON.
